fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  6. #define pb(x) push_back(x)
  7. #define N 100005
  8. #define MOD 1000000007
  9. typedef vector<int> vi;
  10. typedef vector<vi> vvi;
  11. typedef pair<int, int> pii;
  12. typedef long long ll;
  13. typedef unsigned long long ull;
  14.  
  15. int main() {
  16. fastIO;
  17. int n, arcs[N], sumup = 0;
  18. cin >> n;
  19. set<int> cum;
  20. for(int i = 0; i < n; i++)
  21. {
  22. cin >> arcs[i];
  23. sumup += arcs[i];
  24. cum.insert(sumup);
  25. }
  26. cum.erase(sumup);
  27. cum.insert(0);
  28. if(sumup & 1)
  29. {
  30. cout << 'N' << endl;
  31. return 0;
  32. }
  33. int half = sumup / 2, pairs = 0, sumup2 = 0;
  34. for(int i = 0; i < n; i++)
  35. {
  36. sumup2 += arcs[i];
  37. if(cum.find((sumup2 + half) % sumup) != cum.end())
  38. pairs++;
  39. }
  40. if(pairs >= 4)
  41. cout << 'Y' << endl;
  42. else
  43. cout << 'N' << endl;
  44. return 0;
  45. }
Success #stdin #stdout 0s 15504KB
stdin
8

3 3 4 2 6 2 2 2
stdout
Y