Advertisement
smatskevich

Solutions5

Jan 11th, 2022
683
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <algorithm>
  2. #include <cmath>
  3. #include <iostream>
  4. #include <map>
  5. #include <set>
  6. #include <string>
  7. #include <tuple>
  8. #include <unordered_map>
  9. #include <unordered_set>
  10. #include <vector>
  11.  
  12. typedef long long ll;
  13. using namespace std;
  14.  
  15. // Agar.io
  16. int main() {
  17.   ios::sync_with_stdio(false);
  18.   cin.tie(nullptr);
  19.  
  20.   int n = 0;
  21.   cin >> n;
  22.   vector<ll> a(n);
  23.   vector<ll> s(n);
  24.   for (int i = 0; i < n; ++i) {
  25.     cin >> a[i];
  26.     s[i] = a[i] + (i == 0 ? 0 : s[i - 1]);
  27.   }
  28.  
  29.   if (n == 1) {
  30.     cout << 1 << endl;
  31.     return 0;
  32.   }
  33.   int first_cool = 0;
  34.   for (; first_cool < n && a[first_cool] == a[0]; ++first_cool);
  35.  
  36.   for (int i = first_cool; i < n - 1; ++i) {
  37.     if (s[i] <= a[i + 1]) first_cool = i + 1;
  38.   }
  39.   for (int i = 0; i < first_cool; ++i) cout << 0 << endl;
  40.   for (int i = first_cool; i < n; ++i) cout << 1 << endl;
  41.  
  42.   return 0;
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement