Submission #1092495


Source Code Expand

#include <bits/stdc++.h>
#define REP(a,b) for(int a=0; a<(b); ++a)
#define FWD(a,b,c) for(int a=(b); a<(c); ++a)
#define FWDS(a,b,c,d) for(int a=(b); a<(c); a+=d)
#define BCK(a,b,c) for(int a=(b); a>(c); --a)
#define ALL(a) (a).begin(), (a).end()
#define SIZE(a) ((int)(a).size())
#define VAR(x) #x ": " << x << " "
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
#define gcd __gcd
#define x first
#define y second
#define st first
#define nd second
#define pb push_back

using namespace std;

template<typename T> ostream& operator<<(ostream &out, const vector<T> &v){ out << "{"; for(const T &a : v) out << a << ", "; out << "}"; return out; }
template<typename S, typename T> ostream& operator<<(ostream &out, const pair<S,T> &p){ out << "(" << p.st << ", " << p.nd << ")"; return out; }

typedef long long LL;
typedef pair<int, int> PII;
typedef long double K;
typedef vector<int> VI;

const int dx[] = {0,0,-1,1}; //1,1,-1,1};
const int dy[] = {-1,1,0,0}; //1,-1,1,-1};

long long n;
long long sum, ps, vv;
long long A[100010];
long long P[100010];

bool solve(){
	FWD(i,0,n) sum += A[i];
	if(sum % (n*(n+1)/2)) return 0;
	sum /= (n*(n+1)/2);
	FWD(i,0,n){
		P[i] = sum - (A[(i+1)%n] - A[i]);
		if(P[i] % n) return 0;
		P[i] /= n;
		ps += P[i];
		vv += (n-i)*P[i];
	}
	FWD(i,0,n){
		if(vv != A[i]) return 0;
		vv += ps - n*P[i];
	}
	return 1;
}

int main(){
	scanf("%lld", &n);
	FWD(i,0,n) scanf("%lld", &A[i]);
	printf(solve()?"YES\n":"NO\n");;
	return 0;
}

Submission Info

Submission Time
Task B - Boxes
User piob
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1550 Byte
Status WA
Exec Time 19 ms
Memory 1920 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:55:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &n);
                   ^
./Main.cpp:56:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  FWD(i,0,n) scanf("%lld", &A[i]);
                                 ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 3
AC × 25
WA × 5
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 17 ms 1792 KB
in10.txt AC 4 ms 384 KB
in11.txt WA 19 ms 1792 KB
in12.txt WA 19 ms 1792 KB
in13.txt WA 16 ms 1536 KB
in14.txt AC 3 ms 256 KB
in15.txt AC 3 ms 384 KB
in16.txt AC 2 ms 256 KB
in17.txt AC 2 ms 384 KB
in18.txt AC 2 ms 256 KB
in19.txt AC 3 ms 256 KB
in2.txt AC 19 ms 1792 KB
in20.txt AC 2 ms 256 KB
in21.txt AC 15 ms 1152 KB
in22.txt AC 15 ms 1024 KB
in23.txt AC 15 ms 1024 KB
in24.txt AC 3 ms 256 KB
in25.txt AC 4 ms 384 KB
in26.txt WA 19 ms 1792 KB
in27.txt WA 19 ms 1792 KB
in3.txt AC 19 ms 1920 KB
in4.txt AC 19 ms 1792 KB
in5.txt AC 19 ms 1792 KB
in6.txt AC 15 ms 1152 KB
in7.txt AC 15 ms 1024 KB
in8.txt AC 4 ms 384 KB
in9.txt AC 4 ms 384 KB
sample1.txt AC 3 ms 256 KB
sample2.txt AC 2 ms 256 KB
sample3.txt AC 2 ms 256 KB