从这里开始
Problem A Piles With Stones
题目大意
有若干堆石子排成一排。第一天科研人员记录了它们每一堆的数量。第二天科研人员又记录了这些石子的数量。晚上可能有非常多的游客来过。每个游客有三种可选操作:
- 不对石子做什么。
- 拿走一个石子
- 将一个石子移动到另一堆中。
给定两天记录的数据问是否可能。
直接判断第二天的数量是否小于等于第一天。
Code
1 /** 2 * Codeforces 3 * Problem#1013A 4 * Accepted 5 * Time: 31ms 6 * Memory: 0k 7 */ 8 #include <iostream> 9 #include <cstdlib> 10 #include <cstdio> 11 using namespace std; 12 typedef bool boolean; 13 14 int n; 15 int s1 = 0; 16 17 inline void init() { 18 scanf("%d", &n); 19 for (int i = 1, x; i <= n; i++) 20 scanf("%d", &x), s1 += x; 21 for (int i = 1, x; i <= n; i++) 22 scanf("%d", &x), s1 -= x; 23 if (s1 < 0) 24 puts("No"); 25 else 26 puts("Yes"); 27 } 28 29 int main() { 30 init(); 31 return 0; 32 }