Submission
Status:
[PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: Bestzu
Problemset: Bored Cat
Language: cpp
Time: 0.012 second
Submitted On: 2025-10-07 11:19:49
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
const int N = 1e5 + 10;
int a[N];
int main() {
ios::sync_with_stdio(false); cin.tie(0);
int n; cin >> n;
for(int i = 1; i <= n; i++) {
cin >> a[i];
}
for(int i = 2; i < n; i++) {
int diff = a[i-1] - a[i];
a[i] += diff;
a[i+1] += diff;
}
// for(auto e : a) {
// cout << e << " ";
// }
// cout << endl;
if(a[n] == a[1] || n%2 != 0) cout << n;
else cout << n-1;
return 0;
}