Submission #1986181


Source Code Expand

n = int(input())
arr = list(map(int, input().split()))
import math
def findoptimal(diff):
    optimal = 0
    idx = -1
    passed = False

    for i in range(n):
        a = arr[i]
        if passed:
            if abs(a) < optimal:
                optimal = abs(a)
                idx = i
        else:
            if abs(a) > abs(diff):
                passed = True
                optimal = abs(a)
                idx = i
            else:
                if abs(a) > optimal:
                    optimal = abs(a)
                    idx = i

    return idx, arr[idx]

def solve():
    ope = []
    for i in range(n-1):
        while arr[i+1] - arr[i] < 0:
            idx, res = findoptimal(arr[i+1] - arr[i])
            if res < 0:
                ope.append([idx, i])
                arr[i] += res
            else:
                ope.append([idx, i+1])
                arr[i+1] += res

    print(len(ope))
    for i in range(len(ope)):
        print(ope[i][0]+1, ope[i][1]+1)
    # print(ope)
    # print(arr)

solve()

Submission Info

Submission Time
Task D - Non-decreasing
User Y6I
Language Python (3.4.3)
Score 0
Code Size 1072 Byte
Status WA
Exec Time 2109 ms
Memory 85236 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 3
AC × 10
WA × 3
TLE × 29
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 3064 KB
00_example_02.txt AC 17 ms 3064 KB
00_example_03.txt AC 17 ms 3064 KB
01.txt WA 17 ms 3064 KB
02.txt WA 17 ms 3064 KB
03.txt TLE 2106 ms 44660 KB
04.txt WA 28 ms 3956 KB
05.txt TLE 2107 ms 46836 KB
06.txt TLE 2107 ms 48116 KB
07.txt TLE 2105 ms 31348 KB
08.txt TLE 2106 ms 37748 KB
09.txt TLE 2106 ms 37364 KB
10.txt TLE 2106 ms 38004 KB
11.txt TLE 2106 ms 36596 KB
12.txt TLE 2106 ms 39284 KB
13.txt TLE 2107 ms 46580 KB
14.txt TLE 2106 ms 39668 KB
15.txt TLE 2106 ms 39796 KB
16.txt TLE 2106 ms 43636 KB
17.txt TLE 2106 ms 35700 KB
18.txt TLE 2106 ms 36724 KB
19.txt AC 17 ms 3064 KB
20.txt AC 17 ms 3064 KB
21.txt TLE 2106 ms 31220 KB
22.txt TLE 2109 ms 85236 KB
23.txt TLE 2106 ms 34804 KB
24.txt TLE 2107 ms 46068 KB
25.txt TLE 2106 ms 32756 KB
26.txt TLE 2108 ms 65012 KB
27.txt TLE 2105 ms 36852 KB
28.txt TLE 2106 ms 37620 KB
29.txt TLE 2106 ms 31988 KB
30.txt TLE 2106 ms 45172 KB
31.txt AC 17 ms 3064 KB
32.txt AC 17 ms 3064 KB
33.txt AC 17 ms 3064 KB
34.txt TLE 2106 ms 44916 KB
35.txt TLE 2105 ms 38004 KB
36.txt TLE 2106 ms 42484 KB
37.txt TLE 2106 ms 34676 KB
38.txt AC 17 ms 3064 KB
39.txt AC 18 ms 3064 KB