| Task: | Sorting books |
| Sender: | aalto26dw_007 |
| Submission time: | 2026-09-23 17:47:55 +0300 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | details |
| #2 | ACCEPTED | 0.00 s | details |
| #3 | ACCEPTED | 0.00 s | details |
| #4 | ACCEPTED | 0.00 s | details |
| #5 | WRONG ANSWER | 0.00 s | details |
| #6 | WRONG ANSWER | 0.00 s | details |
| #7 | WRONG ANSWER | 0.00 s | details |
| #8 | WRONG ANSWER | 0.00 s | details |
| #9 | WRONG ANSWER | 0.00 s | details |
| #10 | WRONG ANSWER | 0.00 s | details |
| #11 | WRONG ANSWER | 0.00 s | details |
| #12 | WRONG ANSWER | 0.00 s | details |
| #13 | WRONG ANSWER | 0.00 s | details |
| #14 | ACCEPTED | 0.00 s | details |
| #15 | WRONG ANSWER | 0.00 s | details |
| #16 | WRONG ANSWER | 0.00 s | details |
| #17 | WRONG ANSWER | 0.00 s | details |
| #18 | WRONG ANSWER | 0.00 s | details |
| #19 | WRONG ANSWER | 0.00 s | details |
| #20 | WRONG ANSWER | 0.00 s | details |
| #21 | WRONG ANSWER | 0.00 s | details |
| #22 | WRONG ANSWER | 0.00 s | details |
| #23 | WRONG ANSWER | 0.00 s | details |
| #24 | ACCEPTED | 0.00 s | details |
| #25 | WRONG ANSWER | 0.00 s | details |
| #26 | ACCEPTED | 0.00 s | details |
| #27 | ACCEPTED | 0.00 s | details |
| #28 | WRONG ANSWER | 0.00 s | details |
| #29 | WRONG ANSWER | 0.00 s | details |
| #30 | WRONG ANSWER | 0.00 s | details |
| #31 | RUNTIME ERROR | 0.41 s | details |
| #32 | RUNTIME ERROR | 0.41 s | details |
| #33 | RUNTIME ERROR | 0.41 s | details |
| #34 | RUNTIME ERROR | 0.41 s | details |
| #35 | RUNTIME ERROR | 0.42 s | details |
| #36 | RUNTIME ERROR | 0.41 s | details |
| #37 | RUNTIME ERROR | 0.41 s | details |
| #38 | RUNTIME ERROR | 0.41 s | details |
| #39 | RUNTIME ERROR | 0.41 s | details |
| #40 | RUNTIME ERROR | 0.41 s | details |
| #41 | RUNTIME ERROR | 0.41 s | details |
| #42 | RUNTIME ERROR | 0.41 s | details |
| #43 | RUNTIME ERROR | 0.41 s | details |
| #44 | RUNTIME ERROR | 0.41 s | details |
| #45 | RUNTIME ERROR | 0.41 s | details |
| #46 | RUNTIME ERROR | 0.41 s | details |
| #47 | RUNTIME ERROR | 0.41 s | details |
| #48 | RUNTIME ERROR | 0.41 s | details |
| #49 | RUNTIME ERROR | 0.41 s | details |
| #50 | RUNTIME ERROR | 0.41 s | details |
| #51 | RUNTIME ERROR | 0.41 s | details |
| #52 | RUNTIME ERROR | 0.41 s | details |
| #53 | RUNTIME ERROR | 0.41 s | details |
| #54 | RUNTIME ERROR | 0.41 s | details |
| #55 | RUNTIME ERROR | 0.41 s | details |
| #56 | RUNTIME ERROR | 0.41 s | details |
| #57 | RUNTIME ERROR | 0.41 s | details |
| #58 | RUNTIME ERROR | 0.41 s | details |
| #59 | RUNTIME ERROR | 0.41 s | details |
| #60 | RUNTIME ERROR | 0.41 s | details |
| #61 | RUNTIME ERROR | 0.51 s | details |
| #62 | RUNTIME ERROR | 0.51 s | details |
| #63 | RUNTIME ERROR | 0.51 s | details |
| #64 | RUNTIME ERROR | 0.51 s | details |
| #65 | RUNTIME ERROR | 0.51 s | details |
| #66 | RUNTIME ERROR | 0.51 s | details |
| #67 | RUNTIME ERROR | 0.51 s | details |
| #68 | RUNTIME ERROR | 0.51 s | details |
| #69 | RUNTIME ERROR | 0.51 s | details |
| #70 | RUNTIME ERROR | 0.51 s | details |
| #71 | WRONG ANSWER | 0.04 s | details |
Code
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, max = 0;
cin >> n;
vector<int> v(n);
for (int &t : v) {cin >> t; if (t > max) max = t;}
if (n == 1) {
cout << 0;
return 0;
}
vector<int> d(max + 1, -1);
// d[v[0]] = 0;
d[max] = 0;
int ans = 0;
for (int i = 1; i < n; i++) {
for (int j = v[i]; j < max + 1; j++) {
if (d[j] != -1) {
d[v[i]] = d[j] + 1;
break;
}
}
ans += d[v[i]];
}
cout << ans - 1;
}Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 1 1 |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 2 3 7 |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 2 3 6 |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 2 3 8 |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 5
Verdict: WRONG ANSWER
| input |
|---|
| 3 1 2 10 |
| correct output |
|---|
| 0 |
| user output |
|---|
| 1 |
Test 6
Verdict: WRONG ANSWER
| input |
|---|
| 3 3 7 10 |
| correct output |
|---|
| 0 |
| user output |
|---|
| 1 |
Test 7
Verdict: WRONG ANSWER
| input |
|---|
| 3 3 6 8 |
| correct output |
|---|
| 0 |
| user output |
|---|
| 1 |
Test 8
Verdict: WRONG ANSWER
| input |
|---|
| 4 5 5 4 10 |
| correct output |
|---|
| 2 |
| user output |
|---|
| 3 |
Test 9
Verdict: WRONG ANSWER
| input |
|---|
| 4 4 5 5 5 |
| correct output |
|---|
| 0 |
| user output |
|---|
| 5 |
Test 10
Verdict: WRONG ANSWER
| input |
|---|
| 4 7 10 7 1 |
| correct output |
|---|
| 4 |
| user output |
|---|
| 5 |
Test 11
Verdict: WRONG ANSWER
| input |
|---|
| 5 6 6 8 9 7 |
| correct output |
|---|
| 2 |
| user output |
|---|
| 4 |
Test 12
Verdict: WRONG ANSWER
| input |
|---|
| 5 5 10 8 10 1 |
| correct output |
|---|
| 5 |
| user output |
|---|
| 7 |
Test 13
Verdict: WRONG ANSWER
| input |
|---|
| 5 5 2 1 10 6 |
| correct output |
|---|
| 4 |
| user output |
|---|
| 5 |
Test 14
Verdict: ACCEPTED
| input |
|---|
| 5 6 1 8 9 3 |
| correct output |
|---|
| 4 |
| user output |
|---|
| 4 |
Test 15
Verdict: WRONG ANSWER
| input |
|---|
| 5 10 10 6 2 10 |
| correct output |
|---|
| 5 |
| user output |
|---|
| 7 |
Test 16
Verdict: WRONG ANSWER
| input |
|---|
| 5 3 1 9 9 3 |
| correct output |
|---|
| 3 |
| user output |
|---|
| 6 |
Test 17
Verdict: WRONG ANSWER
| input |
|---|
| 5 9 10 4 3 9 |
| correct output |
|---|
| 6 |
| user output |
|---|
| 7 |
Test 18
Verdict: WRONG ANSWER
| input |
|---|
| 5 1 3 8 4 5 |
| correct output |
|---|
| 2 |
| user output |
|---|
| 5 |
Test 19
Verdict: WRONG ANSWER
| input |
|---|
| 5 9 1 10 3 9 |
| correct output |
|---|
| 4 |
| user output |
|---|
| 5 |
Test 20
Verdict: WRONG ANSWER
| input |
|---|
| 5 1 4 6 5 5 |
| correct output |
|---|
| 2 |
| user output |
|---|
| 6 |
Test 21
Verdict: WRONG ANSWER
| input |
|---|
| 10 6 6 8 9 7 9 6 9 5 7 |
| correct output |
|---|
| 18 |
| user output |
|---|
| 17 |
Test 22
Verdict: WRONG ANSWER
| input |
|---|
| 10 5 10 8 10 1 2 4 10 2 3 |
| correct output |
|---|
| 25 |
| user output |
|---|
| 24 |
Test 23
Verdict: WRONG ANSWER
| input |
|---|
| 10 5 2 1 10 6 10 5 5 5 4 |
| correct output |
|---|
| 20 |
| user output |
|---|
| 25 |
Test 24
Verdict: ACCEPTED
| input |
|---|
| 10 6 1 8 9 3 2 6 6 9 5 |
| correct output |
|---|
| 18 |
| user output |
|---|
| 18 |
Test 25
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 10 6 2 10 9 8 7 7 6 |
| correct output |
|---|
| 29 |
| user output |
|---|
| 28 |
Test 26
Verdict: ACCEPTED
| input |
|---|
| 10 3 1 9 9 3 4 10 10 5 1 |
| correct output |
|---|
| 17 |
| user output |
|---|
| 17 |
Test 27
Verdict: ACCEPTED
| input |
|---|
| 10 9 10 4 3 9 1 1 4 2 10 |
| correct output |
|---|
| 25 |
| user output |
|---|
| 25 |
Test 28
Verdict: WRONG ANSWER
| input |
|---|
| 10 1 3 8 4 5 10 8 5 10 4 |
| correct output |
|---|
| 12 |
| user output |
|---|
| 16 |
Test 29
Verdict: WRONG ANSWER
| input |
|---|
| 10 9 1 10 3 9 4 6 9 3 5 |
| correct output |
|---|
| 22 |
| user output |
|---|
| 21 |
Test 30
Verdict: WRONG ANSWER
| input |
|---|
| 10 1 4 6 5 5 1 2 4 2 1 |
| correct output |
|---|
| 25 |
| user output |
|---|
| 18 |
Test 31
Verdict: RUNTIME ERROR
| input |
|---|
| 100 589284012 636562060 767928734 ... |
| correct output |
|---|
| 2843 |
| user output |
|---|
| (empty) |
Test 32
Verdict: RUNTIME ERROR
| input |
|---|
| 100 447773962 773442532 122816 137... |
| correct output |
|---|
| 2446 |
| user output |
|---|
| (empty) |
Test 33
Verdict: RUNTIME ERROR
| input |
|---|
| 100 468145963 198730372 27838076 5... |
| correct output |
|---|
| 2158 |
| user output |
|---|
| (empty) |
Test 34
Verdict: RUNTIME ERROR
| input |
|---|
| 100 591414747 75940263 760367935 9... |
| correct output |
|---|
| 2298 |
| user output |
|---|
| (empty) |
Test 35
Verdict: RUNTIME ERROR
| input |
|---|
| 100 967034924 587586158 185430194 ... |
| correct output |
|---|
| 2580 |
| user output |
|---|
| (empty) |
Test 36
Verdict: RUNTIME ERROR
| input |
|---|
| 100 238363353 59249204 934941692 8... |
| correct output |
|---|
| 2578 |
| user output |
|---|
| (empty) |
Test 37
Verdict: RUNTIME ERROR
| input |
|---|
| 100 958701283 356460601 224848374 ... |
| correct output |
|---|
| 2417 |
| user output |
|---|
| (empty) |
Test 38
Verdict: RUNTIME ERROR
| input |
|---|
| 100 81935404 244103474 837431431 3... |
| correct output |
|---|
| 2315 |
| user output |
|---|
| (empty) |
Test 39
Verdict: RUNTIME ERROR
| input |
|---|
| 100 937837681 11934038 257096283 9... |
| correct output |
|---|
| 2692 |
| user output |
|---|
| (empty) |
Test 40
Verdict: RUNTIME ERROR
| input |
|---|
| 100 11139168 391337048 538883744 5... |
| correct output |
|---|
| 2302 |
| user output |
|---|
| (empty) |
Test 41
Verdict: RUNTIME ERROR
| input |
|---|
| 200 589284012 636562060 767928734 ... |
| correct output |
|---|
| 10624 |
| user output |
|---|
| (empty) |
Test 42
Verdict: RUNTIME ERROR
| input |
|---|
| 200 447773962 773442532 122816 137... |
| correct output |
|---|
| 9384 |
| user output |
|---|
| (empty) |
Test 43
Verdict: RUNTIME ERROR
| input |
|---|
| 200 468145963 198730372 27838076 5... |
| correct output |
|---|
| 8760 |
| user output |
|---|
| (empty) |
Test 44
Verdict: RUNTIME ERROR
| input |
|---|
| 200 591414747 75940263 760367935 9... |
| correct output |
|---|
| 8939 |
| user output |
|---|
| (empty) |
Test 45
Verdict: RUNTIME ERROR
| input |
|---|
| 200 967034924 587586158 185430194 ... |
| correct output |
|---|
| 9905 |
| user output |
|---|
| (empty) |
Test 46
Verdict: RUNTIME ERROR
| input |
|---|
| 200 238363353 59249204 934941692 8... |
| correct output |
|---|
| 9851 |
| user output |
|---|
| (empty) |
Test 47
Verdict: RUNTIME ERROR
| input |
|---|
| 200 958701283 356460601 224848374 ... |
| correct output |
|---|
| 10551 |
| user output |
|---|
| (empty) |
Test 48
Verdict: RUNTIME ERROR
| input |
|---|
| 200 81935404 244103474 837431431 3... |
| correct output |
|---|
| 9163 |
| user output |
|---|
| (empty) |
Test 49
Verdict: RUNTIME ERROR
| input |
|---|
| 200 937837681 11934038 257096283 9... |
| correct output |
|---|
| 9346 |
| user output |
|---|
| (empty) |
Test 50
Verdict: RUNTIME ERROR
| input |
|---|
| 200 11139168 391337048 538883744 5... |
| correct output |
|---|
| 9982 |
| user output |
|---|
| (empty) |
Test 51
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 589284012 636562060 767928734 ... |
| correct output |
|---|
| 256701 |
| user output |
|---|
| (empty) |
Test 52
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 447773962 773442532 122816 137... |
| correct output |
|---|
| 243505 |
| user output |
|---|
| (empty) |
Test 53
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 468145963 198730372 27838076 5... |
| correct output |
|---|
| 252964 |
| user output |
|---|
| (empty) |
Test 54
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 591414747 75940263 760367935 9... |
| correct output |
|---|
| 246581 |
| user output |
|---|
| (empty) |
Test 55
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 967034924 587586158 185430194 ... |
| correct output |
|---|
| 241203 |
| user output |
|---|
| (empty) |
Test 56
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 238363353 59249204 934941692 8... |
| correct output |
|---|
| 251093 |
| user output |
|---|
| (empty) |
Test 57
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 958701283 356460601 224848374 ... |
| correct output |
|---|
| 256962 |
| user output |
|---|
| (empty) |
Test 58
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 81935404 244103474 837431431 3... |
| correct output |
|---|
| 250165 |
| user output |
|---|
| (empty) |
Test 59
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 937837681 11934038 257096283 9... |
| correct output |
|---|
| 246466 |
| user output |
|---|
| (empty) |
Test 60
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 11139168 391337048 538883744 5... |
| correct output |
|---|
| 249076 |
| user output |
|---|
| (empty) |
Test 61
Verdict: RUNTIME ERROR
| input |
|---|
| 200000 589284012 636562060 767928734 ... |
| correct output |
|---|
| 9983154934 |
| user output |
|---|
| (empty) |
Test 62
Verdict: RUNTIME ERROR
| input |
|---|
| 200000 447773962 773442532 122816 137... |
| correct output |
|---|
| 9998885834 |
| user output |
|---|
| (empty) |
Test 63
Verdict: RUNTIME ERROR
| input |
|---|
| 200000 468145963 198730372 27838076 5... |
| correct output |
|---|
| 9995310844 |
| user output |
|---|
| (empty) |
Test 64
Verdict: RUNTIME ERROR
| input |
|---|
| 200000 591414747 75940263 760367935 9... |
| correct output |
|---|
| 10000936270 |
| user output |
|---|
| (empty) |
Test 65
Verdict: RUNTIME ERROR
| input |
|---|
| 200000 967034924 587586158 185430194 ... |
| correct output |
|---|
| 10002145347 |
| user output |
|---|
| (empty) |
Test 66
Verdict: RUNTIME ERROR
| input |
|---|
| 200000 238363353 59249204 934941692 8... |
| correct output |
|---|
| 9989708150 |
| user output |
|---|
| (empty) |
Test 67
Verdict: RUNTIME ERROR
| input |
|---|
| 200000 958701283 356460601 224848374 ... |
| correct output |
|---|
| 9997845631 |
| user output |
|---|
| (empty) |
Test 68
Verdict: RUNTIME ERROR
| input |
|---|
| 200000 81935404 244103474 837431431 3... |
| correct output |
|---|
| 10016175198 |
| user output |
|---|
| (empty) |
Test 69
Verdict: RUNTIME ERROR
| input |
|---|
| 200000 937837681 11934038 257096283 9... |
| correct output |
|---|
| 9983428867 |
| user output |
|---|
| (empty) |
Test 70
Verdict: RUNTIME ERROR
| input |
|---|
| 200000 11139168 391337048 538883744 5... |
| correct output |
|---|
| 9971613818 |
| user output |
|---|
| (empty) |
Test 71
Verdict: WRONG ANSWER
| input |
|---|
| 200000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
| correct output |
|---|
| 0 |
| user output |
|---|
| -1474936481 |
