Submission #1093585
Source Code Expand
#include<bits/stdc++.h> #define int long long int #define MP make_pair #define PB push_back #define F first #define S second using namespace std; typedef vector<int> VI; typedef pair<int, int> PII; typedef vector<PII> VP; typedef pair<PII, int> PPI; const int INF = 3e18; int n, a[100010]; int *p[200010]; int pls[200010], mns[200010]; signed main() { cin >> n; for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 0; i < n; i++){ p[i] = p[n + i] = &a[i]; } for(int i = 0; i < n; i++){ if(*p[i] >= *p[i + 1]){ int diff = *p[i] - *p[i + 1]; if(diff % (n - 1) == 0){ pls[i + 1] += diff / (n - 1); mns[i + n] += diff / (n - 1); } else{ pls[i + 1] += diff / (n - 1) + 1; mns[i + n] += diff / (n - 1) + 1; } } } int now = 0, many = 0; for(int i = 0; i < 2 * n; i++){ now += pls[i]; many += pls[i]; *p[i] -= now; many -= mns[i]; now -= mns[i] * n; now += many; } bool flag = true; for(int i = 0; i < n; i++){ if(*p[i]) flag = false; } cout << (flag ? "YES" : "NO") << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Boxes |
User | yuki681 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1158 Byte |
Status | RE |
Exec Time | 142 ms |
Memory | 4096 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
in1.txt | AC | 46 ms | 2688 KB |
in10.txt | AC | 9 ms | 512 KB |
in11.txt | AC | 70 ms | 2560 KB |
in12.txt | AC | 71 ms | 2560 KB |
in13.txt | AC | 53 ms | 2176 KB |
in14.txt | RE | 142 ms | 256 KB |
in15.txt | RE | 113 ms | 256 KB |
in16.txt | AC | 3 ms | 256 KB |
in17.txt | AC | 3 ms | 256 KB |
in18.txt | AC | 3 ms | 256 KB |
in19.txt | AC | 3 ms | 256 KB |
in2.txt | AC | 67 ms | 4096 KB |
in20.txt | AC | 3 ms | 256 KB |
in21.txt | AC | 72 ms | 4096 KB |
in22.txt | AC | 72 ms | 4096 KB |
in23.txt | AC | 72 ms | 4096 KB |
in24.txt | AC | 6 ms | 384 KB |
in25.txt | AC | 9 ms | 512 KB |
in26.txt | AC | 69 ms | 2560 KB |
in27.txt | AC | 62 ms | 2560 KB |
in3.txt | AC | 72 ms | 4096 KB |
in4.txt | AC | 68 ms | 2816 KB |
in5.txt | AC | 68 ms | 2688 KB |
in6.txt | AC | 71 ms | 2944 KB |
in7.txt | AC | 66 ms | 4096 KB |
in8.txt | AC | 8 ms | 512 KB |
in9.txt | AC | 9 ms | 512 KB |
sample1.txt | AC | 2 ms | 256 KB |
sample2.txt | AC | 3 ms | 256 KB |
sample3.txt | AC | 2 ms | 256 KB |