Submission #3046288
Source Code Expand
n = int(input()) a = list(map(int, input().split())) # 絶対値の差列をとる diff = [a[i+1] - a[i] for i in range(n-1)] # max,minをパレットに格納 max_a = max(a) max_a_id = a.index(max_a) min_a = min(a) min_a_id = a.index(min_a) path_plus = [] if not all([ai < 0 for ai in a]): # maxを足していく方針 i = 0 while any([d < 0 for d in diff]): if diff[i] >= 0: i += 1 continue elif i == n-2: diff[i] += max_a path_plus.append(( max_a_id+1, i+2)) else: diff[i] += max_a a[i] += max_a diff[i+1] -= max_a max_a = max(max_a, a[i]) path_plus.append(( max_a_id+1, i+2)) path_minus = [] if not all([ai > 0 for ai in a]): # minを引いていく方針 i = n-2 while any([d < 0 for d in diff]): if diff[i] >= 0: i -= 1 continue elif i == 0: diff[i] -= min_a path_minus.append((min_a_id+1, i+1)) else: diff[i] -= min_a a[i] += min_a diff[i-1] += min_a min_a = min(min_a, a[i]) path_minus.append(( min_a_id+1, i+1)) if (len(path_plus) > 0) and (len(path_plus) <= 2*n): print(len(path_plus)) for x,y in path_plus: print(x,y) elif (len(path_minus) > 0) and (len(path_minus) <= 2*n): print(len(path_minus)) for x,y in path_minus: print(x,y) else: print(0)
Submission Info
Submission Time | |
---|---|
Task | D - Non-decreasing |
User | polarbear08 |
Language | Python (3.4.3) |
Score | 0 |
Code Size | 1683 Byte |
Status | WA |
Exec Time | 2114 ms |
Memory | 164912 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 600 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt |
All | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 17 ms | 3188 KB |
00_example_02.txt | AC | 17 ms | 3188 KB |
00_example_03.txt | AC | 17 ms | 3188 KB |
01.txt | WA | 17 ms | 3188 KB |
02.txt | WA | 18 ms | 3188 KB |
03.txt | WA | 18 ms | 3188 KB |
04.txt | WA | 17 ms | 3188 KB |
05.txt | WA | 17 ms | 3064 KB |
06.txt | WA | 18 ms | 3188 KB |
07.txt | WA | 18 ms | 3188 KB |
08.txt | WA | 18 ms | 3188 KB |
09.txt | WA | 18 ms | 3188 KB |
10.txt | WA | 18 ms | 3188 KB |
11.txt | WA | 18 ms | 3188 KB |
12.txt | WA | 18 ms | 3188 KB |
13.txt | WA | 18 ms | 3188 KB |
14.txt | WA | 18 ms | 3188 KB |
15.txt | WA | 18 ms | 3188 KB |
16.txt | WA | 18 ms | 3188 KB |
17.txt | TLE | 2106 ms | 45744 KB |
18.txt | TLE | 2106 ms | 44976 KB |
19.txt | AC | 17 ms | 3188 KB |
20.txt | AC | 17 ms | 3188 KB |
21.txt | WA | 18 ms | 3188 KB |
22.txt | WA | 17 ms | 3192 KB |
23.txt | WA | 18 ms | 3188 KB |
24.txt | WA | 18 ms | 3188 KB |
25.txt | WA | 18 ms | 3188 KB |
26.txt | WA | 17 ms | 3188 KB |
27.txt | WA | 18 ms | 3188 KB |
28.txt | WA | 18 ms | 3188 KB |
29.txt | WA | 18 ms | 3188 KB |
30.txt | WA | 18 ms | 3188 KB |
31.txt | AC | 17 ms | 3188 KB |
32.txt | TLE | 2114 ms | 164912 KB |
33.txt | AC | 17 ms | 3188 KB |
34.txt | WA | 18 ms | 3188 KB |
35.txt | WA | 18 ms | 3188 KB |
36.txt | WA | 18 ms | 3188 KB |
37.txt | WA | 18 ms | 3188 KB |
38.txt | AC | 17 ms | 3188 KB |
39.txt | AC | 18 ms | 3188 KB |