Submission #1093568
Source Code Expand
#include<cstdio> #include<cstdlib> #include<cmath> #include<iostream> #include<string> #include<stack> #include<queue> #include<vector> #include<tuple> #include<map> #include<set> #include<algorithm> #define rep(n) for(int i=0;i<n;i++) #define repp(j, n) for(int j=0;j<n;j++) #define reppp(i, m, n) for(int i=m;i<=n;i++) #define all(c) c.begin(), c.end() #define MOD 1000000007 #define MAX 1000000001 #define INF 1410065408 using namespace std; typedef long long ll; typedef pair<ll, ll> P; struct edge{int from, to; ll cost;}; signed main(){ ll n, sum = 0, sun_n; cin >> n; ll a[n]; rep(n){ cin >> a[i]; sum += a[i]; } if(n==1){ cout << "YES"; return 0; } double sum_n = (double)sum / (n * (n+1) / 2); if(sum_n != (ll)sum_n){ cout << "NO"; return 0; } ll m = (ll)sum_n; ll diff = a[0] - a[n-1]; ll d_count = m, i = 1; while(true){ ll d = 0; ll diff_calc = m; while(diff != diff_calc && d_count >= 0){ d++; diff_calc = diff_calc - 1 - (n-1) * d; d_count--; } if(diff != diff_calc){ cout << "NO"; return 0; } if(i >= n){ break; } diff = a[i] - a[i-1]; i++; } if(d_count == 0){ cout << "YES"; return 0; }else{ cout << "NO"; return 0; } }
Submission Info
Submission Time | |
---|---|
Task | B - Boxes |
User | Noimin |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1303 Byte |
Status | WA |
Exec Time | 383 ms |
Memory | 1024 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 | 50 ms | 1024 KB |
in10.txt | AC | 9 ms | 256 KB |
in11.txt | AC | 68 ms | 1024 KB |
in12.txt | AC | 68 ms | 1024 KB |
in13.txt | AC | 61 ms | 896 KB |
in14.txt | AC | 3 ms | 256 KB |
in15.txt | AC | 3 ms | 256 KB |
in16.txt | AC | 2 ms | 256 KB |
in17.txt | WA | 383 ms | 256 KB |
in18.txt | WA | 381 ms | 256 KB |
in19.txt | AC | 3 ms | 256 KB |
in2.txt | WA | 69 ms | 1024 KB |
in20.txt | AC | 3 ms | 256 KB |
in21.txt | AC | 67 ms | 1024 KB |
in22.txt | AC | 56 ms | 1024 KB |
in23.txt | AC | 67 ms | 1024 KB |
in24.txt | AC | 5 ms | 256 KB |
in25.txt | AC | 8 ms | 256 KB |
in26.txt | AC | 64 ms | 1024 KB |
in27.txt | AC | 67 ms | 1024 KB |
in3.txt | WA | 68 ms | 1024 KB |
in4.txt | WA | 66 ms | 1024 KB |
in5.txt | WA | 69 ms | 1024 KB |
in6.txt | AC | 56 ms | 1024 KB |
in7.txt | AC | 55 ms | 1024 KB |
in8.txt | AC | 8 ms | 256 KB |
in9.txt | AC | 9 ms | 256 KB |
sample1.txt | AC | 3 ms | 256 KB |
sample2.txt | AC | 3 ms | 256 KB |
sample3.txt | AC | 3 ms | 256 KB |