Submission #1358617
Source Code Expand
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; class Main { public static void main(String args[]) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); Solver solver = new Solver(); solver.init(); solver.readHead(in.readLine()); for (; solver.hasNext();) { solver.readBody(in.readLine()); } } } class Solver { int N; int cnt; public void init() { N = 0; cnt = 0; } public void readHead(String str) { String[] strArr = str.split(" "); N = Integer.parseInt(strArr[0]); // System.out.println(N); } public boolean hasNext() { // return cnt < N; return cnt < 1; } public void readBody(String str) { // System.out.println(str); cnt++; String[] strArr = str.split(" "); long sum = 0; for (int i = 0; i < N; i++) { sum += Long.parseLong(strArr[i]); } long k = sum / (N * (N + 1) / 2); boolean able = true; long edge = 0; for (int i = 0; i < N; i++) { long d = -Long.parseLong(strArr[i]) - k; if (i == N - 1) d += Long.parseLong(strArr[0]); else d += Long.parseLong(strArr[i + 1]); // System.out.println(d); if (d > 0) { able = false; break; } if (d < 0) { if (d % N != 0) { able = false; break; } edge -= d; } } // if (able) { // // System.out.println(edge); // able = (edge == N * k); // } if (able) System.out.println("YES"); else System.out.println("NO"); } }
Submission Info
Submission Time | |
---|---|
Task | B - Boxes |
User | idon |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 1577 Byte |
Status | WA |
Exec Time | 191 ms |
Memory | 40028 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, sample1.txt, sample2.txt, sample3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
in1.txt | WA | 172 ms | 34076 KB |
in10.txt | AC | 115 ms | 20308 KB |
in11.txt | AC | 173 ms | 35156 KB |
in12.txt | AC | 177 ms | 37584 KB |
in13.txt | AC | 168 ms | 35100 KB |
in14.txt | AC | 68 ms | 21332 KB |
in15.txt | AC | 68 ms | 20180 KB |
in16.txt | WA | 69 ms | 20692 KB |
in17.txt | AC | 69 ms | 19028 KB |
in18.txt | AC | 68 ms | 17876 KB |
in19.txt | AC | 70 ms | 20436 KB |
in2.txt | WA | 180 ms | 36436 KB |
in20.txt | AC | 69 ms | 20820 KB |
in21.txt | AC | 183 ms | 34900 KB |
in22.txt | AC | 164 ms | 34900 KB |
in23.txt | AC | 175 ms | 37332 KB |
in24.txt | AC | 85 ms | 19540 KB |
in25.txt | AC | 117 ms | 22228 KB |
in26.txt | AC | 174 ms | 35156 KB |
in27.txt | AC | 183 ms | 37596 KB |
in3.txt | WA | 191 ms | 36564 KB |
in4.txt | WA | 187 ms | 38108 KB |
in5.txt | WA | 184 ms | 40028 KB |
in6.txt | AC | 163 ms | 35412 KB |
in7.txt | AC | 164 ms | 37460 KB |
in8.txt | AC | 114 ms | 23124 KB |
in9.txt | AC | 103 ms | 23508 KB |
sample1.txt | AC | 71 ms | 22996 KB |
sample2.txt | AC | 68 ms | 18900 KB |
sample3.txt | AC | 68 ms | 20820 KB |