Submission #1093360
Source Code Expand
/* You lost the game. */
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cfloat>
#include <numeric>
#include <cassert>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <vector>
#define fin(i,n) for (int i = 0; i < n; i++)
#define fin2(i,a,b) for (int i = a; i < b; i++)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define mod 1000000009
#define si(n) scanf("%d", &n)
#define sii(n,m) scanf("%d %d", &n, &m)
#define siii(n,m,k) scanf("%d %d %d", &n, &m, &k)
#define sl(n) scanf("%lld", &n)
#define sll(n,m) scanf("%lld %lld", &n, &m)
#define slll(n,m,k) scanf("%lld %lld %lld", &n, &m, &k)
#define ss(s) scanf("%s", s)
#define sai(t,n) fin(i,n) { scanf("%d", &t[i]); }
#define sal(t,n) fin(i,n) { scanf("%lld", &t[i]); }
#define pi(n) printf("%d\n", n)
#define pc(n) printf("%c\n", n)
#define ps(s) printf("%s\n", s);
#define pii(n,m) printf("%d %d\n", n, m)
#define pl(n) printf("%lld\n", n)
#define pll(n,m) printf("%lld %lld\n", n, m)
#define pai(t,n) fin(i,n) { printf("%d ", t[i]); } printf("\n");
#define pal(t,n) fin(i,n) { printf("%lld ", t[i]); } printf("\n");
#define L long long int
#define D double
#define PII pair<int, int>
#define VPII vector<PII>
#define VL vector<L>
#define VI vector<int>
#define VVI vector<VI>
using namespace std;
int main() {
L n, tab[100000];
sl(n);
sal(tab, n);
L s = 0;
fin(i, n) { s += tab[i]; }
L d = n*(n+1)/2;
if (n == 1) { printf("YES"); return 0; }
if (s % d > 0) { printf("NO"); return 0; }
L m = s / d;
while (1) {
L minimum = tab[0], indice = 0;
fin2(i, 1, n) {
if (tab[i] < minimum) { indice = i; minimum = tab[i]; }
}
L j;
fin2(i, indice, indice+n) {
if (i >= n) { j = i-n; } else { j = i; }
tab[j] -= ((L) i-indice+1);
}
L ok = 0, s = 0, idem = 1;
fin(i, n) {
if (tab[i] < 0) { ok = 2; }
if (tab[i] == 0) { ok = 1; }
if (tab[i] != tab[0]) { idem = 0; }
s += tab[i];
}
if (ok == 1 && s > 0) { printf("NO"); return 0; }
else if (ok == 1 && s == 0) { printf("YES"); return 0; }
else if (ok == 2) { printf("NO"); return 0; }
else if (idem == 1) { printf("YES"); return 0; }
}
}
Submission Info
| Submission Time |
|
| Task |
B - Boxes |
| User |
noelnadal |
| Language |
C++14 (GCC 5.4.1) |
| Score |
0 |
| Code Size |
2610 Byte |
| Status |
WA |
| Exec Time |
2102 ms |
| Memory |
1024 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:63:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
sl(n);
^
./Main.cpp:40:49: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
#define sal(t,n) fin(i,n) { scanf("%lld", &t[i]); }
^
./Main.cpp:64:5: note: in expansion of macro ‘sal’
sal(tab, n);
^
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 |
17 ms |
1024 KiB |
| in10.txt |
WA |
1465 ms |
384 KiB |
| in11.txt |
TLE |
2102 ms |
1024 KiB |
| in12.txt |
TLE |
2102 ms |
1024 KiB |
| in13.txt |
AC |
503 ms |
896 KiB |
| in14.txt |
AC |
3 ms |
256 KiB |
| in15.txt |
AC |
3 ms |
256 KiB |
| in16.txt |
AC |
3 ms |
256 KiB |
| in17.txt |
TLE |
2102 ms |
256 KiB |
| in18.txt |
TLE |
2102 ms |
256 KiB |
| in19.txt |
AC |
3 ms |
256 KiB |
| in2.txt |
TLE |
2102 ms |
1024 KiB |
| in20.txt |
AC |
3 ms |
256 KiB |
| in21.txt |
AC |
15 ms |
1024 KiB |
| in22.txt |
AC |
15 ms |
1024 KiB |
| in23.txt |
AC |
15 ms |
1024 KiB |
| in24.txt |
WA |
203 ms |
256 KiB |
| in25.txt |
WA |
872 ms |
384 KiB |
| in26.txt |
AC |
680 ms |
1024 KiB |
| in27.txt |
AC |
1520 ms |
1024 KiB |
| in3.txt |
TLE |
2102 ms |
1024 KiB |
| in4.txt |
TLE |
2102 ms |
1024 KiB |
| in5.txt |
TLE |
2102 ms |
1024 KiB |
| in6.txt |
AC |
15 ms |
1024 KiB |
| in7.txt |
AC |
15 ms |
1024 KiB |
| in8.txt |
WA |
328 ms |
384 KiB |
| in9.txt |
WA |
1624 ms |
384 KiB |
| sample1.txt |
AC |
3 ms |
256 KiB |
| sample2.txt |
AC |
3 ms |
256 KiB |
| sample3.txt |
AC |
3 ms |
256 KiB |