QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#182845 | #5662. Distance Calculator | bonginn | AC ✓ | 1ms | 3816kb | C++14 | 621b | 2023-09-18 16:54:21 | 2023-09-18 16:54:21 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define IOS cin.tie(0);ios_base::sync_with_stdio(false);
#define INF 1e15+9
using namespace std;
const int maxn = 2e5+5;
typedef pair<int,int> P;
void solve(){
int n;
cin >> n;
vector <int> a(n+5);
for(int i=1;i<=n;i++) cin >> a[i];
int ans = 0;
for(int i=2;i<=n;i++){
for(int j=1;j<i;j++){
if(a[i] < a[j]) ans ++;
}
}
cout << ans << '\n';
}
signed main(){IOS
int T;
cin >> T;
while(T--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3816kb
input:
5 3 3 1 2 4 4 3 2 1 5 4 1 2 3 5 7 2 6 1 5 4 3 7 10 3 2 1 5 7 6 4 10 8 9
output:
2 6 3 8 9
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
4 5 1 3 5 4 2 5 3 1 2 5 4 3 1 2 3 6 5 3 1 6 2 4
output:
4 3 0 8
result:
ok 4 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
5 6 1 3 2 4 6 5 4 4 1 3 2 5 3 5 4 1 2 6 2 5 3 1 6 4 3 2 1 3
output:
2 4 7 6 1
result:
ok 5 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
6 3 1 3 2 6 3 5 6 1 2 4 5 5 3 1 2 4 6 5 3 4 6 2 1 5 4 5 1 3 2 6 4 1 3 5 2 6
output:
1 8 6 11 7 5
result:
ok 6 lines
Test #5:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
6 5 1 4 2 3 5 3 3 1 2 6 4 6 2 3 5 1 6 5 2 3 1 6 4 6 3 2 1 4 5 6 3 3 1 2
output:
2 2 10 7 3 2
result:
ok 6 lines
Test #6:
score: 0
Accepted
time: 0ms
memory: 3472kb
input:
4 6 5 1 3 4 6 2 4 4 2 1 3 5 1 5 4 3 2 4 1 2 3 4
output:
7 4 6 0
result:
ok 4 lines
Test #7:
score: 0
Accepted
time: 0ms
memory: 3476kb
input:
7 4 3 2 1 4 5 1 3 2 4 5 5 3 1 5 2 4 5 2 4 5 1 3 4 1 4 3 2 4 4 3 2 1 3 3 2 1
output:
3 1 4 5 3 6 3
result:
ok 7 lines
Test #8:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
4 5 3 1 5 4 2 6 1 4 6 5 2 3 4 3 2 1 4 5 2 5 1 4 3
output:
5 7 3 5
result:
ok 4 lines
Test #9:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
11 9 5 2 7 1 8 4 9 3 6 23 11 15 4 2 6 3 14 8 19 22 16 7 23 10 13 17 5 21 20 1 9 12 18 17 14 4 6 17 7 10 16 1 11 3 5 12 13 9 2 15 8 29 5 7 12 9 24 11 18 23 1 16 6 14 21 27 10 28 20 4 2 29 3 19 22 17 15 13 8 26 25 9 4 2 5 1 7 9 8 6 3 15 2 12 6 3 9 15 8 11 1 4 5 14 13 10 7 19 8 9 10 2 13 1 19 4 3 5 14 ...
output:
15 104 69 169 14 45 55 47 38 77 195
result:
ok 11 lines
Test #10:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
18 21 4 16 21 20 17 10 18 3 13 9 8 15 11 6 12 5 7 1 19 2 14 26 25 3 23 6 17 4 2 1 8 16 18 15 12 14 7 9 13 19 24 26 21 20 5 10 22 11 15 15 4 2 3 11 1 8 5 14 12 7 13 10 6 9 11 10 9 3 5 6 4 7 2 1 11 8 25 3 10 23 15 25 1 19 7 16 24 13 6 22 12 21 4 11 8 20 5 2 14 18 17 9 21 21 3 18 2 20 1 12 16 15 5 6 10...
output:
135 135 45 31 162 111 25 96 107 176 166 186 53 28 285 155 44 152
result:
ok 18 lines
Test #11:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
15 14 10 7 4 12 1 2 9 6 11 13 5 14 8 3 21 9 4 8 20 14 15 18 5 17 11 16 3 2 6 19 7 10 1 12 21 13 14 7 4 14 8 10 12 11 9 2 13 3 6 1 5 19 16 14 2 6 7 5 17 15 12 8 3 9 19 1 11 13 18 4 10 28 28 10 27 11 18 24 17 9 16 2 12 14 23 25 21 13 22 15 20 26 6 1 5 19 4 7 3 8 14 12 1 10 6 13 2 8 14 5 3 7 9 4 11 23 ...
output:
42 104 57 84 244 45 117 31 89 131 24 139 214 69 192
result:
ok 15 lines
Test #12:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
39 37 16 20 14 32 26 9 21 37 27 25 22 2 10 36 6 29 4 24 17 28 35 18 30 7 19 12 1 13 5 3 33 23 11 15 8 31 34 41 38 3 13 26 16 28 17 29 10 32 15 2 33 35 36 18 14 24 31 12 11 40 25 34 27 9 6 8 19 21 7 23 37 20 4 41 5 1 22 39 30 49 4 9 43 27 2 15 28 39 34 26 24 19 32 30 38 18 44 23 42 35 45 49 21 22 47 ...
output:
358 420 616 574 1474 713 277 1482 981 169 882 1147 330 761 1405 547 990 364 532 445 551 1389 1521 421 742 1151 1535 1592 671 822 1448 1112 1284 326 1125 1506 801 529 220
result:
ok 39 lines
Test #13:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
30 33 7 2 27 29 23 25 32 4 15 18 26 3 28 5 11 1 19 9 8 16 20 30 13 24 33 12 10 6 21 14 17 22 31 48 47 41 44 34 32 30 4 36 24 45 26 25 8 16 12 6 7 48 38 27 2 37 28 22 14 43 10 13 17 35 1 46 11 40 23 29 21 18 31 19 33 5 42 9 39 3 15 20 73 52 10 59 20 46 6 35 70 55 22 12 3 2 31 7 57 37 42 28 71 64 17 5...
output:
245 658 1253 1371 256 1004 1179 541 436 1066 328 632 421 764 728 465 457 579 883 1126 867 1277 726 845 573 1162 711 1329 1356 653
result:
ok 30 lines
Test #14:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
23 68 4 63 28 23 61 31 3 32 43 24 44 20 54 5 36 19 48 56 11 33 65 46 60 6 52 22 29 30 39 50 47 35 26 14 25 1 8 13 66 64 12 37 15 27 58 53 45 17 68 41 2 21 7 10 55 40 18 42 38 67 34 59 9 57 62 49 16 51 51 26 22 1 15 44 6 8 21 2 45 10 16 41 37 33 19 14 38 9 50 49 17 18 32 48 7 4 13 35 5 31 29 24 39 46...
output:
1063 530 531 686 347 1049 930 361 420 1456 453 810 933 1367 253 854 407 512 490 554 1037 651 1008
result:
ok 23 lines
Test #15:
score: 0
Accepted
time: 0ms
memory: 3480kb
input:
23 74 74 24 52 57 62 11 73 43 12 35 7 22 64 44 61 55 36 58 50 42 56 16 26 67 18 46 70 51 68 48 4 49 63 47 39 54 34 28 5 30 19 15 1 32 6 8 21 27 60 25 29 66 69 14 13 20 72 37 10 33 17 31 3 38 45 65 40 41 59 71 2 23 9 53 78 74 13 7 32 50 60 29 56 62 44 46 55 69 22 30 39 68 6 31 11 40 37 35 78 12 26 1 ...
output:
1533 1496 1269 527 1134 480 227 463 274 1289 508 298 937 422 865 271 899 937 478 538 636 1279 915
result:
ok 23 lines
Test #16:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
25 58 48 7 49 42 29 41 17 40 54 34 9 22 55 27 58 25 14 53 38 46 43 4 51 47 3 1 30 35 57 2 31 36 20 32 50 6 39 5 11 10 15 23 52 37 44 21 19 18 16 45 24 28 13 56 8 33 12 26 40 28 14 32 33 22 6 10 39 13 36 24 20 30 23 17 12 18 35 19 15 37 8 1 11 2 7 9 5 31 4 34 38 26 29 40 27 16 3 21 25 59 42 6 31 16 4...
output:
946 419 904 1463 228 263 925 878 349 238 1478 672 530 291 1036 288 301 1461 538 1231 1098 666 1538 913 581
result:
ok 25 lines
Test #17:
score: 0
Accepted
time: 1ms
memory: 3608kb
input:
43 81 61 1 36 8 29 43 19 46 77 52 51 73 74 63 33 50 47 16 41 17 64 20 44 13 27 60 35 31 12 26 18 14 40 38 79 6 25 65 42 7 32 37 72 81 10 62 54 78 30 58 56 66 21 80 69 75 55 48 45 11 5 4 53 67 39 76 34 15 59 71 22 57 68 2 3 23 28 70 9 49 24 90 57 74 79 26 41 29 69 54 82 87 77 43 53 25 7 85 55 73 72 1...
output:
1615 2180 1707 2353 1865 1584 2091 1949 1663 1721 2123 2028 2095 2447 1832 2624 2033 2161 1594 2558 2471 2201 2063 1681 1727 2517 1749 1632 2220 2139 2506 1770 1829 2182 2130 2062 2299 2343 1827 1597 2348 2426 2080
result:
ok 43 lines
Test #18:
score: 0
Accepted
time: 1ms
memory: 3488kb
input:
42 97 90 45 36 52 19 93 33 7 80 21 94 59 35 83 55 30 12 34 37 64 27 61 8 54 40 81 53 73 1 31 70 67 49 77 32 76 58 66 92 89 10 26 11 25 84 43 4 79 78 96 75 85 86 6 39 68 2 22 97 24 14 48 9 72 23 57 65 20 44 5 69 74 95 56 15 50 82 13 88 28 3 41 46 62 71 17 18 51 42 38 91 16 29 60 63 87 47 82 5 24 69 1...
output:
2367 1715 2488 2177 2449 1748 2157 2292 2418 2442 2572 2538 1993 1551 2178 1753 2488 2035 1486 1750 1838 2262 2371 1545 2186 1915 2140 1808 1627 2475 2039 1523 2188 1739 1830 2431 1864 1904 2350 1651 1758 1664
result:
ok 42 lines
Test #19:
score: 0
Accepted
time: 1ms
memory: 3544kb
input:
47 85 47 36 35 67 17 29 73 81 49 27 33 61 80 14 8 7 3 44 30 26 65 22 42 13 45 62 69 32 50 70 68 31 40 46 11 2 75 25 56 16 55 57 23 59 78 72 77 79 9 51 41 28 37 21 53 58 24 20 83 54 18 64 52 1 6 34 85 10 82 15 63 60 76 38 5 71 4 39 43 84 19 74 12 66 48 100 88 73 45 35 54 57 29 67 13 71 87 95 30 53 93...
output:
1722 2744 1705 2369 1831 1778 2241 1674 1735 1614 1798 2568 2315 2219 2083 2078 2490 1773 2479 1930 2300 1744 2629 1872 1688 1893 2088 1835 1989 2389 2229 2386 1606 1515 1846 2319 1795 2203 2181 1749 2363 1607 1895 2395 1701 1601 2390
result:
ok 47 lines
Test #20:
score: 0
Accepted
time: 1ms
memory: 3560kb
input:
49 98 50 34 49 78 3 90 53 7 40 55 81 72 47 95 2 43 80 48 37 5 65 30 32 71 62 57 73 27 22 10 45 60 35 41 77 66 28 82 97 1 96 16 61 74 26 93 64 79 17 75 31 58 52 21 39 88 86 98 14 70 24 29 20 42 46 56 18 44 9 59 51 69 6 25 91 84 54 12 94 89 67 87 36 4 8 13 33 15 23 63 68 85 92 83 38 76 19 11 89 54 20 ...
output:
2412 1999 2477 2074 2159 2265 2425 2249 1686 2496 2214 1687 1679 1510 2448 1636 1697 1440 1967 1892 2066 1786 2101 1872 1391 2300 2548 1588 2353 2338 1828 2487 1635 1868 1681 1823 2274 1831 2287 1634 1746 2028 2294 1983 2457 1987 1878 1847 1983
result:
ok 49 lines
Test #21:
score: 0
Accepted
time: 1ms
memory: 3520kb
input:
45 82 54 42 2 16 46 66 74 24 13 28 47 40 45 53 39 4 1 34 33 17 5 80 48 11 49 67 52 35 56 55 81 27 10 78 23 63 69 7 60 50 79 32 18 12 6 15 8 29 25 59 61 73 20 68 51 64 14 41 31 30 62 77 43 21 71 38 26 82 9 19 44 22 70 3 72 75 37 58 36 65 76 57 86 20 15 75 37 45 63 82 14 68 2 77 1 7 65 74 57 66 11 79 ...
output:
1466 1784 2247 2107 1854 1751 2414 1618 2391 1996 1809 2352 2506 1951 2187 2693 2150 1690 2569 1760 1983 2298 1739 1917 1784 1609 2445 1433 2091 1898 1614 1664 2223 2135 2037 1620 1762 1941 2098 2504 2268 1794 2365 1888 2586
result:
ok 45 lines