Submission #1092452


Source Code Expand

#include<bits/stdc++.h>
#define ll long long

const int N = 100010;

ll n, a[N], cnt[N], pre[N];

int main(){
	scanf("%I64d", &n);
	ll sum = 0, one = n * (n + 1) / 2;
	for (int i = 0; i < n; ++ i){
		scanf("%I64d", &a[i]);
		sum += a[i];
	}
	if (sum % one){
		return printf("NO\n"), 0;
	}
	ll times = sum / one;
	for (int i = n - 2; i >= 0; -- i){
		ll x = a[i] - (a[n - 1] - times * (n - 1 - i));
		if (x % n){
			return printf("NO\n"), 0;
		}
		cnt[i] = x / n - pre[i + 1];
		if (cnt[i] < 0){
			return printf("NO\n"), 0;
		}
		pre[i] = pre[i + 1] + cnt[i];
	}
	return printf("YES\n"), 0;
}

Submission Info

Submission Time
Task B - Boxes
User zhongzihao
Language C++14 (GCC 5.4.1)
Score 500
Code Size 622 Byte
Status AC
Exec Time 66 ms
Memory 2560 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:9:19: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=]
  scanf("%I64d", &n);
                   ^
./Main.cpp:12:23: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=]
   scanf("%I64d", &a[i]);
                       ^
./Main.cpp:9:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%I64d", &n);
                    ^
./Main.cpp:12:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%I64d", &a[i]);
                        ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 30
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 44 ms 2560 KB
in10.txt AC 8 ms 384 KB
in11.txt AC 59 ms 2560 KB
in12.txt AC 59 ms 2560 KB
in13.txt AC 50 ms 2176 KB
in14.txt AC 2 ms 256 KB
in15.txt AC 2 ms 256 KB
in16.txt AC 3 ms 256 KB
in17.txt AC 2 ms 256 KB
in18.txt AC 3 ms 256 KB
in19.txt AC 3 ms 256 KB
in2.txt AC 52 ms 2560 KB
in20.txt AC 2 ms 256 KB
in21.txt AC 60 ms 1024 KB
in22.txt AC 60 ms 1024 KB
in23.txt AC 60 ms 1024 KB
in24.txt AC 5 ms 256 KB
in25.txt AC 8 ms 384 KB
in26.txt AC 56 ms 2560 KB
in27.txt AC 58 ms 2560 KB
in3.txt AC 66 ms 2560 KB
in4.txt AC 60 ms 2560 KB
in5.txt AC 60 ms 2560 KB
in6.txt AC 58 ms 1024 KB
in7.txt AC 55 ms 1024 KB
in8.txt AC 8 ms 384 KB
in9.txt AC 8 ms 384 KB
sample1.txt AC 3 ms 256 KB
sample2.txt AC 3 ms 256 KB
sample3.txt AC 2 ms 256 KB