Submission #255282

# Submission time Handle Problem Language Result Execution time Memory
255282 2020-07-31T17:02:52 Z model_code Labels (NOI20_labels) Java 11
100 / 100
428 ms 36496 KB
import java.io.DataInputStream;
import java.io.IOException;
import java.io.BufferedOutputStream;
import java.io.BufferedWriter;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.lang.StringBuilder;

public class Labels {
    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;
        public Reader() {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }
        public int nextInt() throws IOException {
            int ret = 0;
            Boolean flip = false;
            byte c = read();
            while (c < '0' || c > '9') {
                if (c == '-') flip = true;
                c = read();
            }
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            return flip ? -ret : ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1) {
                buffer[0] = -1;
            }
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead) {
                fillBuffer();
            }
            return buffer[bufferPointer++];
        }
    }

    public static void main(String[] args) throws IOException {
        Reader reader = new Reader();
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
        int N = reader.nextInt();
        int D[] = new int[N+1];
        int P[] = new int[N+1];
        int maxn = 0, minn = 0;
        for (int a = 0; a < N - 1; ++a) {
            D[a] = reader.nextInt();
            if (a>0) D[a] += D[a - 1];
            maxn = Math.max(maxn, D[a]);
            minn = Math.min(minn, D[a]);
        }
        if (maxn - minn != N - 1) {
            System.out.println("-1");
            System.exit(0);
        }
        P[0] = N - maxn;
        for (int a = 1; a < N; ++a) P[a] = P[0] + D[a - 1];
        for (int a = 0; a < N; ++a) {
            out.write(Integer.toString(P[a]));
            if (a == N - 1) out.write("\n");
            else out.write(" ");
        }
        out.flush();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 73 ms 10384 KB Output is correct
2 Correct 74 ms 10284 KB Output is correct
3 Correct 75 ms 10172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 10384 KB Output is correct
2 Correct 74 ms 10284 KB Output is correct
3 Correct 75 ms 10172 KB Output is correct
4 Correct 77 ms 10116 KB Output is correct
5 Correct 83 ms 10400 KB Output is correct
6 Correct 89 ms 10308 KB Output is correct
7 Correct 74 ms 10212 KB Output is correct
8 Correct 78 ms 10172 KB Output is correct
9 Correct 72 ms 10008 KB Output is correct
10 Correct 75 ms 10232 KB Output is correct
11 Correct 80 ms 10064 KB Output is correct
12 Correct 80 ms 10064 KB Output is correct
13 Correct 79 ms 10184 KB Output is correct
14 Correct 76 ms 10144 KB Output is correct
15 Correct 81 ms 10260 KB Output is correct
16 Correct 88 ms 9964 KB Output is correct
17 Correct 79 ms 10044 KB Output is correct
18 Correct 79 ms 10184 KB Output is correct
19 Correct 83 ms 10056 KB Output is correct
20 Correct 78 ms 10356 KB Output is correct
21 Correct 87 ms 10216 KB Output is correct
22 Correct 79 ms 10208 KB Output is correct
23 Correct 78 ms 10184 KB Output is correct
24 Correct 86 ms 10304 KB Output is correct
25 Correct 75 ms 10052 KB Output is correct
26 Correct 84 ms 10252 KB Output is correct
27 Correct 80 ms 10200 KB Output is correct
28 Correct 76 ms 10108 KB Output is correct
29 Correct 84 ms 10096 KB Output is correct
30 Correct 78 ms 10268 KB Output is correct
31 Correct 79 ms 10344 KB Output is correct
32 Correct 85 ms 10292 KB Output is correct
33 Correct 75 ms 10308 KB Output is correct
34 Correct 72 ms 10108 KB Output is correct
35 Correct 74 ms 10120 KB Output is correct
36 Correct 71 ms 10232 KB Output is correct
37 Correct 76 ms 10340 KB Output is correct
38 Correct 74 ms 10176 KB Output is correct
39 Correct 77 ms 10204 KB Output is correct
40 Correct 72 ms 10024 KB Output is correct
41 Correct 71 ms 10184 KB Output is correct
42 Correct 77 ms 10108 KB Output is correct
43 Correct 76 ms 10212 KB Output is correct
44 Correct 77 ms 10160 KB Output is correct
45 Correct 76 ms 10140 KB Output is correct
46 Correct 79 ms 10124 KB Output is correct
47 Correct 71 ms 10140 KB Output is correct
48 Correct 81 ms 10184 KB Output is correct
49 Correct 86 ms 10148 KB Output is correct
50 Correct 79 ms 10068 KB Output is correct
51 Correct 78 ms 10092 KB Output is correct
52 Correct 79 ms 10248 KB Output is correct
53 Correct 87 ms 10148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 10384 KB Output is correct
2 Correct 74 ms 10284 KB Output is correct
3 Correct 75 ms 10172 KB Output is correct
4 Correct 77 ms 10116 KB Output is correct
5 Correct 83 ms 10400 KB Output is correct
6 Correct 89 ms 10308 KB Output is correct
7 Correct 74 ms 10212 KB Output is correct
8 Correct 78 ms 10172 KB Output is correct
9 Correct 72 ms 10008 KB Output is correct
10 Correct 75 ms 10232 KB Output is correct
11 Correct 80 ms 10064 KB Output is correct
12 Correct 80 ms 10064 KB Output is correct
13 Correct 79 ms 10184 KB Output is correct
14 Correct 76 ms 10144 KB Output is correct
15 Correct 81 ms 10260 KB Output is correct
16 Correct 88 ms 9964 KB Output is correct
17 Correct 79 ms 10044 KB Output is correct
18 Correct 79 ms 10184 KB Output is correct
19 Correct 83 ms 10056 KB Output is correct
20 Correct 78 ms 10356 KB Output is correct
21 Correct 87 ms 10216 KB Output is correct
22 Correct 79 ms 10208 KB Output is correct
23 Correct 78 ms 10184 KB Output is correct
24 Correct 86 ms 10304 KB Output is correct
25 Correct 75 ms 10052 KB Output is correct
26 Correct 84 ms 10252 KB Output is correct
27 Correct 80 ms 10200 KB Output is correct
28 Correct 76 ms 10108 KB Output is correct
29 Correct 84 ms 10096 KB Output is correct
30 Correct 78 ms 10268 KB Output is correct
31 Correct 79 ms 10344 KB Output is correct
32 Correct 85 ms 10292 KB Output is correct
33 Correct 75 ms 10308 KB Output is correct
34 Correct 72 ms 10108 KB Output is correct
35 Correct 74 ms 10120 KB Output is correct
36 Correct 71 ms 10232 KB Output is correct
37 Correct 76 ms 10340 KB Output is correct
38 Correct 74 ms 10176 KB Output is correct
39 Correct 77 ms 10204 KB Output is correct
40 Correct 72 ms 10024 KB Output is correct
41 Correct 71 ms 10184 KB Output is correct
42 Correct 77 ms 10108 KB Output is correct
43 Correct 76 ms 10212 KB Output is correct
44 Correct 77 ms 10160 KB Output is correct
45 Correct 76 ms 10140 KB Output is correct
46 Correct 79 ms 10124 KB Output is correct
47 Correct 71 ms 10140 KB Output is correct
48 Correct 81 ms 10184 KB Output is correct
49 Correct 86 ms 10148 KB Output is correct
50 Correct 79 ms 10068 KB Output is correct
51 Correct 78 ms 10092 KB Output is correct
52 Correct 79 ms 10248 KB Output is correct
53 Correct 87 ms 10148 KB Output is correct
54 Correct 89 ms 10172 KB Output is correct
55 Correct 80 ms 10180 KB Output is correct
56 Correct 89 ms 10184 KB Output is correct
57 Correct 90 ms 9920 KB Output is correct
58 Correct 104 ms 10216 KB Output is correct
59 Correct 87 ms 10220 KB Output is correct
60 Correct 87 ms 10248 KB Output is correct
61 Correct 94 ms 10264 KB Output is correct
62 Correct 74 ms 10268 KB Output is correct
63 Correct 91 ms 10300 KB Output is correct
64 Correct 100 ms 10396 KB Output is correct
65 Correct 83 ms 10280 KB Output is correct
66 Correct 82 ms 10452 KB Output is correct
67 Correct 84 ms 10244 KB Output is correct
68 Correct 81 ms 10224 KB Output is correct
69 Correct 80 ms 10256 KB Output is correct
70 Correct 81 ms 10084 KB Output is correct
71 Correct 72 ms 10064 KB Output is correct
72 Correct 81 ms 10220 KB Output is correct
73 Correct 86 ms 10256 KB Output is correct
74 Correct 107 ms 10104 KB Output is correct
75 Correct 82 ms 10164 KB Output is correct
76 Correct 97 ms 10236 KB Output is correct
77 Correct 82 ms 10308 KB Output is correct
78 Correct 89 ms 10420 KB Output is correct
79 Correct 80 ms 10292 KB Output is correct
80 Correct 91 ms 10352 KB Output is correct
81 Correct 83 ms 9960 KB Output is correct
82 Correct 93 ms 10252 KB Output is correct
83 Correct 81 ms 10240 KB Output is correct
84 Correct 110 ms 10132 KB Output is correct
85 Correct 110 ms 9992 KB Output is correct
86 Correct 90 ms 10416 KB Output is correct
87 Correct 81 ms 10184 KB Output is correct
88 Correct 90 ms 10016 KB Output is correct
89 Correct 83 ms 10440 KB Output is correct
90 Correct 78 ms 10388 KB Output is correct
91 Correct 77 ms 10140 KB Output is correct
92 Correct 79 ms 10284 KB Output is correct
93 Correct 76 ms 10340 KB Output is correct
94 Correct 83 ms 10160 KB Output is correct
95 Correct 85 ms 10096 KB Output is correct
96 Correct 77 ms 10112 KB Output is correct
97 Correct 82 ms 10000 KB Output is correct
98 Correct 84 ms 10260 KB Output is correct
99 Correct 77 ms 10200 KB Output is correct
100 Correct 88 ms 10132 KB Output is correct
101 Correct 88 ms 10560 KB Output is correct
102 Correct 77 ms 10252 KB Output is correct
103 Correct 83 ms 10212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 377 ms 35892 KB Output is correct
2 Correct 76 ms 10204 KB Output is correct
3 Correct 315 ms 30460 KB Output is correct
4 Correct 114 ms 13204 KB Output is correct
5 Correct 125 ms 13188 KB Output is correct
6 Correct 124 ms 13004 KB Output is correct
7 Correct 118 ms 12960 KB Output is correct
8 Correct 125 ms 13064 KB Output is correct
9 Correct 81 ms 10128 KB Output is correct
10 Correct 76 ms 10104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 10384 KB Output is correct
2 Correct 74 ms 10284 KB Output is correct
3 Correct 75 ms 10172 KB Output is correct
4 Correct 77 ms 10116 KB Output is correct
5 Correct 83 ms 10400 KB Output is correct
6 Correct 89 ms 10308 KB Output is correct
7 Correct 74 ms 10212 KB Output is correct
8 Correct 78 ms 10172 KB Output is correct
9 Correct 72 ms 10008 KB Output is correct
10 Correct 75 ms 10232 KB Output is correct
11 Correct 80 ms 10064 KB Output is correct
12 Correct 80 ms 10064 KB Output is correct
13 Correct 79 ms 10184 KB Output is correct
14 Correct 76 ms 10144 KB Output is correct
15 Correct 81 ms 10260 KB Output is correct
16 Correct 88 ms 9964 KB Output is correct
17 Correct 79 ms 10044 KB Output is correct
18 Correct 79 ms 10184 KB Output is correct
19 Correct 83 ms 10056 KB Output is correct
20 Correct 78 ms 10356 KB Output is correct
21 Correct 87 ms 10216 KB Output is correct
22 Correct 79 ms 10208 KB Output is correct
23 Correct 78 ms 10184 KB Output is correct
24 Correct 86 ms 10304 KB Output is correct
25 Correct 75 ms 10052 KB Output is correct
26 Correct 84 ms 10252 KB Output is correct
27 Correct 80 ms 10200 KB Output is correct
28 Correct 76 ms 10108 KB Output is correct
29 Correct 84 ms 10096 KB Output is correct
30 Correct 78 ms 10268 KB Output is correct
31 Correct 79 ms 10344 KB Output is correct
32 Correct 85 ms 10292 KB Output is correct
33 Correct 75 ms 10308 KB Output is correct
34 Correct 72 ms 10108 KB Output is correct
35 Correct 74 ms 10120 KB Output is correct
36 Correct 71 ms 10232 KB Output is correct
37 Correct 76 ms 10340 KB Output is correct
38 Correct 74 ms 10176 KB Output is correct
39 Correct 77 ms 10204 KB Output is correct
40 Correct 72 ms 10024 KB Output is correct
41 Correct 71 ms 10184 KB Output is correct
42 Correct 77 ms 10108 KB Output is correct
43 Correct 76 ms 10212 KB Output is correct
44 Correct 77 ms 10160 KB Output is correct
45 Correct 76 ms 10140 KB Output is correct
46 Correct 79 ms 10124 KB Output is correct
47 Correct 71 ms 10140 KB Output is correct
48 Correct 81 ms 10184 KB Output is correct
49 Correct 86 ms 10148 KB Output is correct
50 Correct 79 ms 10068 KB Output is correct
51 Correct 78 ms 10092 KB Output is correct
52 Correct 79 ms 10248 KB Output is correct
53 Correct 87 ms 10148 KB Output is correct
54 Correct 89 ms 10172 KB Output is correct
55 Correct 80 ms 10180 KB Output is correct
56 Correct 89 ms 10184 KB Output is correct
57 Correct 90 ms 9920 KB Output is correct
58 Correct 104 ms 10216 KB Output is correct
59 Correct 87 ms 10220 KB Output is correct
60 Correct 87 ms 10248 KB Output is correct
61 Correct 94 ms 10264 KB Output is correct
62 Correct 74 ms 10268 KB Output is correct
63 Correct 91 ms 10300 KB Output is correct
64 Correct 100 ms 10396 KB Output is correct
65 Correct 83 ms 10280 KB Output is correct
66 Correct 82 ms 10452 KB Output is correct
67 Correct 84 ms 10244 KB Output is correct
68 Correct 81 ms 10224 KB Output is correct
69 Correct 80 ms 10256 KB Output is correct
70 Correct 81 ms 10084 KB Output is correct
71 Correct 72 ms 10064 KB Output is correct
72 Correct 81 ms 10220 KB Output is correct
73 Correct 86 ms 10256 KB Output is correct
74 Correct 107 ms 10104 KB Output is correct
75 Correct 82 ms 10164 KB Output is correct
76 Correct 97 ms 10236 KB Output is correct
77 Correct 82 ms 10308 KB Output is correct
78 Correct 89 ms 10420 KB Output is correct
79 Correct 80 ms 10292 KB Output is correct
80 Correct 91 ms 10352 KB Output is correct
81 Correct 83 ms 9960 KB Output is correct
82 Correct 93 ms 10252 KB Output is correct
83 Correct 81 ms 10240 KB Output is correct
84 Correct 110 ms 10132 KB Output is correct
85 Correct 110 ms 9992 KB Output is correct
86 Correct 90 ms 10416 KB Output is correct
87 Correct 81 ms 10184 KB Output is correct
88 Correct 90 ms 10016 KB Output is correct
89 Correct 83 ms 10440 KB Output is correct
90 Correct 78 ms 10388 KB Output is correct
91 Correct 77 ms 10140 KB Output is correct
92 Correct 79 ms 10284 KB Output is correct
93 Correct 76 ms 10340 KB Output is correct
94 Correct 83 ms 10160 KB Output is correct
95 Correct 85 ms 10096 KB Output is correct
96 Correct 77 ms 10112 KB Output is correct
97 Correct 82 ms 10000 KB Output is correct
98 Correct 84 ms 10260 KB Output is correct
99 Correct 77 ms 10200 KB Output is correct
100 Correct 88 ms 10132 KB Output is correct
101 Correct 88 ms 10560 KB Output is correct
102 Correct 77 ms 10252 KB Output is correct
103 Correct 83 ms 10212 KB Output is correct
104 Correct 377 ms 35892 KB Output is correct
105 Correct 76 ms 10204 KB Output is correct
106 Correct 315 ms 30460 KB Output is correct
107 Correct 114 ms 13204 KB Output is correct
108 Correct 125 ms 13188 KB Output is correct
109 Correct 124 ms 13004 KB Output is correct
110 Correct 118 ms 12960 KB Output is correct
111 Correct 125 ms 13064 KB Output is correct
112 Correct 81 ms 10128 KB Output is correct
113 Correct 76 ms 10104 KB Output is correct
114 Correct 136 ms 13280 KB Output is correct
115 Correct 330 ms 32696 KB Output is correct
116 Correct 142 ms 13428 KB Output is correct
117 Correct 138 ms 13296 KB Output is correct
118 Correct 335 ms 31884 KB Output is correct
119 Correct 150 ms 13372 KB Output is correct
120 Correct 428 ms 31108 KB Output is correct
121 Correct 351 ms 31956 KB Output is correct
122 Correct 352 ms 30124 KB Output is correct
123 Correct 134 ms 13284 KB Output is correct
124 Correct 309 ms 32676 KB Output is correct
125 Correct 341 ms 30736 KB Output is correct
126 Correct 312 ms 29816 KB Output is correct
127 Correct 327 ms 31376 KB Output is correct
128 Correct 131 ms 13324 KB Output is correct
129 Correct 305 ms 34236 KB Output is correct
130 Correct 320 ms 31848 KB Output is correct
131 Correct 310 ms 31032 KB Output is correct
132 Correct 347 ms 29224 KB Output is correct
133 Correct 401 ms 31096 KB Output is correct
134 Correct 134 ms 13168 KB Output is correct
135 Correct 314 ms 33504 KB Output is correct
136 Correct 137 ms 13272 KB Output is correct
137 Correct 140 ms 13348 KB Output is correct
138 Correct 125 ms 13208 KB Output is correct
139 Correct 141 ms 13272 KB Output is correct
140 Correct 137 ms 13300 KB Output is correct
141 Correct 127 ms 13428 KB Output is correct
142 Correct 360 ms 36496 KB Output is correct
143 Correct 136 ms 13212 KB Output is correct
144 Correct 147 ms 13444 KB Output is correct
145 Correct 323 ms 32788 KB Output is correct
146 Correct 318 ms 31832 KB Output is correct
147 Correct 365 ms 30164 KB Output is correct
148 Correct 380 ms 30548 KB Output is correct
149 Correct 359 ms 33164 KB Output is correct
150 Correct 353 ms 30948 KB Output is correct
151 Correct 122 ms 12980 KB Output is correct
152 Correct 122 ms 13180 KB Output is correct
153 Correct 133 ms 13264 KB Output is correct
154 Correct 160 ms 13048 KB Output is correct
155 Correct 132 ms 13744 KB Output is correct
156 Correct 71 ms 10224 KB Output is correct
157 Correct 68 ms 10232 KB Output is correct
158 Correct 130 ms 13416 KB Output is correct
159 Correct 74 ms 10056 KB Output is correct
160 Correct 327 ms 32936 KB Output is correct
161 Correct 130 ms 13288 KB Output is correct
162 Correct 139 ms 13292 KB Output is correct
163 Correct 135 ms 13336 KB Output is correct