Submission #1131056


Source Code Expand

#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<int> A(N);
	long long sum =0;
	for(int i =0; i < N; i++) {
		cin >> A[i];
		sum +=A[i];}
	int steps =0;
	while(sum > 0) {
		sum -=1LL*N*(N+1)/2;
		steps++;}
	if(sum < 0) {
		cout << "NO\n";
		return 0;}

	vector<int> dif(N);
	for(int i =0; i < N; i++) dif[i] =A[i]-A[(i+N-1)%N]-steps;
	for(int i =0; i < N; i++) if(dif[i]%N != 0 || dif[i] > 0) {
		cout << "NO\n";
		return 0;}
	vector<int> apl(N,0);
	for(int i =0; i < N; i++) {
		apl[i] =(-dif[i])/N;
		steps -=apl[i];}
	if(steps != 0) {
		cout << "NO\n";
		return 0;}
	cout << "YES\n";
	return 0;}

// look at my code
// my code is amazing

Submission Info

Submission Time
Task B - Boxes
User xellos
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1592 Byte
Status AC
Exec Time 325 ms
Memory 1408 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 33
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 11 ms 1408 KB
in10.txt AC 2 ms 384 KB
in11.txt AC 12 ms 1024 KB
in12.txt AC 12 ms 1024 KB
in13.txt AC 10 ms 896 KB
in14.txt AC 1 ms 256 KB
in15.txt AC 325 ms 256 KB
in16.txt AC 217 ms 256 KB
in17.txt AC 163 ms 256 KB
in18.txt AC 164 ms 256 KB
in19.txt AC 1 ms 256 KB
in2.txt AC 13 ms 1408 KB
in20.txt AC 1 ms 256 KB
in21.txt AC 11 ms 640 KB
in22.txt AC 11 ms 640 KB
in23.txt AC 11 ms 640 KB
in24.txt AC 2 ms 256 KB
in25.txt AC 2 ms 384 KB
in26.txt AC 12 ms 1024 KB
in27.txt AC 12 ms 1024 KB
in3.txt AC 13 ms 1408 KB
in4.txt AC 13 ms 1408 KB
in5.txt AC 13 ms 1408 KB
in6.txt AC 11 ms 640 KB
in7.txt AC 11 ms 640 KB
in8.txt AC 2 ms 384 KB
in9.txt AC 2 ms 384 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB
sample3.txt AC 1 ms 256 KB