Submission #1654382
Source Code Expand
// Example program #include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 1; typedef long long int ll; ll a[MAXN]; int main() { ll n; ll x = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; x += a[i]; } if (x % ((n * (n + 1)) / 2) == 0) { ll u = 0; for (int i = 0; i < n; i++) if (a[i] > u) u = a[i]; for (int i = 2; i < n; i++) { if (a[i] == u && a[i - 1] != u && a[i - 2] == u) { cout << "NO"; return ; } } sort(a, a + n); for (int i = 0; i < n; i++) { if (a[i] < (x / ((n * (n + 1)) / 2)) + i) { cout << "NO"; return 0; } } if (a[n - 1] > ((x / ((n * (n + 1)) / 2)) * n)) { cout << "NO"; return 0; } for (int i = 1; i < n; i++) { if (a[i] > a[i - 1] + n) { cout << "NO"; return 0; } } cout << "YES"; } else cout << "NO"; }
Submission Info
Submission Time | |
---|---|
Task | B - Boxes |
User | vjudge5 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1199 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:33:17: error: return-statement with no value, in function returning ‘int’ [-fpermissive] return ; ^