Submission #1373037
Source Code Expand
#include <bits/stdc++.h> #define pii pair<int, int> #define f first #define s second #define pb push_back #define mp make_pair #define ll long long #define ull unsigned long long #define ld long double #define sz(v) int(v.size()) #define all(v) v.begin(), v.end() #define y1 what using namespace std; const int N = (int) 1e6 + 10; const int M = (int) 101; const ll big = (1LL << 51); const ll LINF = (ll) 1e18; const int INF = (int) 1e9 + 7; const int INF1 = (int) 1e9 + 3; const double EPS = (double) 1e-6; const double PI = 3.14159265359; int n; int a[N], b[N]; int main() { #define fn "balls" #ifdef witch freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #else // freopen(fn".in", "r", stdin); // freopen(fn".out", "w", stdout); #endif srand(time(0)); cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { b[i] = a[(i + 1) % n] - a[i]; } ll sum1 = 0, sum2 = (n * 1ll * (n + 1)) / 2; for (int i = 0; i < n; i++) { sum1 += a[i]; } if (sum1 % sum2) { cout << "NO"; return 0; } ll cnt = sum1 / sum2; sum1 = 0; for (int i = 0; i < n; i++) { if (b[i] > cnt || (cnt - b[i]) % n) { sum1 = -1; break; } sum1 += (cnt - b[i]) / n; } if (sum1 == cnt) { cout << "YES"; } else { cout << "NO"; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Boxes |
User | Nurlykhan |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1558 Byte |
Status | AC |
Exec Time | 57 ms |
Memory | 5244 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 500 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt, sample3.txt |
All | sample1.txt, sample2.txt, sample3.txt, in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in2.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample1.txt, sample2.txt, sample3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
in1.txt | AC | 49 ms | 5244 KB |
in10.txt | AC | 7 ms | 2304 KB |
in11.txt | AC | 57 ms | 4736 KB |
in12.txt | AC | 55 ms | 4736 KB |
in13.txt | AC | 46 ms | 4736 KB |
in14.txt | AC | 2 ms | 2304 KB |
in15.txt | AC | 2 ms | 2304 KB |
in16.txt | AC | 2 ms | 2304 KB |
in17.txt | AC | 2 ms | 2304 KB |
in18.txt | AC | 2 ms | 2304 KB |
in19.txt | AC | 2 ms | 2304 KB |
in2.txt | AC | 57 ms | 4736 KB |
in20.txt | AC | 2 ms | 2304 KB |
in21.txt | AC | 54 ms | 4736 KB |
in22.txt | AC | 55 ms | 4736 KB |
in23.txt | AC | 54 ms | 4736 KB |
in24.txt | AC | 4 ms | 2304 KB |
in25.txt | AC | 7 ms | 2304 KB |
in26.txt | AC | 54 ms | 4736 KB |
in27.txt | AC | 54 ms | 4736 KB |
in3.txt | AC | 57 ms | 4736 KB |
in4.txt | AC | 56 ms | 4736 KB |
in5.txt | AC | 57 ms | 4736 KB |
in6.txt | AC | 55 ms | 4736 KB |
in7.txt | AC | 55 ms | 4736 KB |
in8.txt | AC | 6 ms | 2304 KB |
in9.txt | AC | 7 ms | 2304 KB |
sample1.txt | AC | 2 ms | 2304 KB |
sample2.txt | AC | 2 ms | 2304 KB |
sample3.txt | AC | 2 ms | 2304 KB |