QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#103658#6104. Building Bombingtonygu03WA 14ms8120kbPython31010b2023-05-07 06:38:472023-05-07 06:38:49

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-07 06:38:49]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:8120kb
  • [2023-05-07 06:38:47]
  • 提交

answer

import math
 
 
info = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]
N, L, K = info[0], info[1], info[2]
if K > N - L:
    print(-1)
    exit(0)
table = [[0 for i in range(N)] for j in range(N)]
for i in range(1, N):
    for j in range(N - i, N):
        table[i][j] = math.inf
for i in range(N - 1):
    c = 0
    for j in range(i + 1, N):
        if arr[j] > arr[i]:
            c += 1
    table[i][0] = c
for i in range(1, N):
    for j in range(N - i):
        table[j][i] = math.inf
        c = 0
        for k in range(j + 1, N - i + 1):
            if arr[k] > arr[j]:
                # c += 1
                table[j][i] = min(table[j][i], table[k][i - 1] + c)
                c += 1
c = 0
for i in range(L - 1):
    if arr[i] >= arr[L - 1]:
        c += 1
if table[L - 1][K - 1] == math.inf:
    print(-1)
else:
    print(table[L - 1][K - 1] + c)
# for item in table:
#     print(item)
    
# print(table[0][0])
# print(table[0][-1])

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 10ms
memory: 8120kb

input:

7 2 3
10 30 90 40 60 60 80

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 7ms
memory: 8080kb

input:

3 2 2
30 20 10

output:

-1

result:

ok 1 number(s): "-1"

Test #3:

score: -100
Wrong Answer
time: 14ms
memory: 8016kb

input:

1 1 1
608954134

output:

-1

result:

wrong answer 1st numbers differ - expected: '0', found: '-1'