QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#408295 | #2296. Exchange Students | Andycipation | AC ✓ | 804ms | 133184kb | C++20 | 3.5kb | 2024-05-09 23:48:00 | 2024-05-09 23:48:02 |
Judging History
answer
/*
* author: ADMathNoob
* created: 05/08/24 14:04:52
* problem: https://qoj.ac/problem/2296
*/
/*
Comments about problem:
*/
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...) 42
#endif
template <typename T>
class Fenwick {
public:
const int n;
const int max_power; // smallest power of 2 larger than n
vector<T> tree;
Fenwick(int _n) : n(_n), max_power(1 << (32 - __builtin_clz(n))), tree(n) {
assert(n > 0);
}
T get(int x) const {
assert(-1 <= x && x < n);
T res{};
while (x >= 0) {
res += tree[x];
x = (x & (x + 1)) - 1;
}
return res;
}
void modify(int x, T v) {
assert(0 <= x && x < n);
while (x < n) {
tree[x] += v;
x |= (x + 1);
}
}
};
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<int> init(n);
map<int, vector<int>> pos1;
for (int i = 0; i < n; i++) {
cin >> init[i];
pos1[init[i]].push_back(i);
}
map<int, vector<int>> pos2;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
pos2[x].push_back(i);
}
Fenwick<int> ft1(n), ft2(n);
for (int i = 0; i < n; i++) {
ft1.modify(i, +1);
ft2.modify(i, +1);
}
long long ans = 0;
for (auto [h, st] : pos1) {
auto fin = pos2[h];
int k = st.size();
for (int z = 0; z < k; z++) {
ans += abs(ft2.get(fin[z]) - ft1.get(st[z]));
}
for (int z = 0; z < k; z++) {
ft1.modify(st[z], -1);
ft2.modify(fin[z], -1);
}
}
cout << ans << '\n';
const int OPS = 200000;
vector<pair<int, int>> ops;
set<int> alive;
for (int i = 0; i < n; i++) {
alive.insert(i);
}
map<int, set<int>> pos;
for (auto [h, v] : pos1) {
pos[h] = set<int>(v.begin(), v.end());
}
auto a = init;
auto Do = [&](int i, int j) {
assert(a[i] != a[j]);
ops.emplace_back(i, j);
if (ops.size() == OPS) {
for (auto [x, y] : ops) {
cout << x + 1 << ' ' << y + 1 << '\n';
}
exit(0);
}
pos[a[i]].erase(i);
pos[a[j]].erase(j);
pos[a[i]].insert(j);
pos[a[j]].insert(i);
swap(a[i], a[j]);
};
auto GetL = [&](int i) {
auto it = alive.find(i);
return *prev(it);
};
auto GetR = [&](int i) {
auto it = alive.find(i);
return *next(it);
};
for (int i = 0; i < n; i++) {
ft1.modify(i, +1);
ft2.modify(i, +1);
}
vector<int> heights = init;
sort(heights.begin(), heights.end());
heights.resize(unique(heights.begin(), heights.end()) - heights.begin());
for (int h : heights) {
vector<int> st(pos[h].begin(), pos[h].end());
assert(is_sorted(st.begin(), st.end()));
vector<int> fin = pos2[h];
int k = st.size();
vector<int> goL, goR;
for (int z = 0; z < k; z++) {
if (ft1.get(st[z]) > ft2.get(fin[z])) {
goL.push_back(z);
}
if (ft1.get(st[z]) < ft2.get(fin[z])) {
goR.push_back(z);
}
}
reverse(goR.begin(), goR.end());
debug(goL, goR);
for (int z : goL) {
int i = st[z];
while (i != fin[z]) {
int j = GetL(i);
Do(i, j);
i = j;
}
}
for (int z : goR) {
int i = st[z];
while (i != fin[z]) {
int j = GetR(i);
Do(i, j);
i = j;
}
}
for (int i : fin) {
alive.erase(i);
}
}
for (auto [x, y] : ops) {
cout << x + 1 << ' ' << y + 1 << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3532kb
input:
1 279122803 279122803
output:
0
result:
ok good
Test #2:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
2 212545283 896408766 212545283 896408766
output:
0
result:
ok good
Test #3:
score: 0
Accepted
time: 0ms
memory: 3524kb
input:
4 3 1 2 4 4 2 1 3
output:
2 2 3 1 4
result:
ok good
Test #4:
score: 0
Accepted
time: 1ms
memory: 3568kb
input:
6 5 1 2 3 4 6 6 4 3 2 1 5
output:
7 2 3 3 4 4 5 2 3 3 4 2 3 1 6
result:
ok good
Test #5:
score: 0
Accepted
time: 1ms
memory: 3744kb
input:
2 2 1 1 2
output:
1 2 1
result:
ok good
Test #6:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
4 3 2 2 1 2 1 2 3
output:
4 4 3 3 2 3 1 4 3
result:
ok good
Test #7:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
9 708443928 333343028 130113530 997808421 299459189 845949632 647591888 681805948 468112900 299459189 997808421 130113530 845949632 647591888 681805948 468112900 708443928 333343028
output:
13 5 4 4 2 2 1 4 5 5 6 6 7 7 8 8 9 8 7 6 5 8 6 2 4 4 8
result:
ok good
Test #8:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
3 732684994 647116406 457545388 732684994 647116406 457545388
output:
0
result:
ok good
Test #9:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
4 105385396 776935185 411665343 757889658 776935185 411665343 757889658 105385396
output:
3 1 2 2 3 3 4
result:
ok good
Test #10:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
4 1 2 2 1 2 2 1 1
output:
2 1 2 2 3
result:
ok good
Test #11:
score: 0
Accepted
time: 1ms
memory: 3560kb
input:
10 1 2 1 2 1 1 2 2 2 1 1 2 2 2 2 1 1 2 1 1
output:
8 6 7 7 8 8 9 5 6 6 7 3 4 4 5 5 6
result:
ok good
Test #12:
score: 0
Accepted
time: 1ms
memory: 3528kb
input:
5 1 1 2 2 2 2 1 1 2 2
output:
2 2 3 1 2
result:
ok good
Test #13:
score: 0
Accepted
time: 1ms
memory: 3528kb
input:
10 1 2 1 3 2 2 3 3 1 2 1 2 2 2 2 3 3 1 3 1
output:
11 9 10 3 4 4 5 5 6 6 7 7 8 4 3 5 4 9 7 7 6 6 5
result:
ok good
Test #14:
score: 0
Accepted
time: 0ms
memory: 3508kb
input:
6 4 2 1 4 1 4 4 1 2 1 4 4
output:
2 3 2 5 4
result:
ok good
Test #15:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
6 4 5 4 6 5 2 5 4 2 4 5 6
output:
5 6 5 5 4 4 3 1 2 6 5
result:
ok good
Test #16:
score: 0
Accepted
time: 0ms
memory: 3436kb
input:
6 4 3 8 5 1 2 5 8 2 4 1 3
output:
7 6 4 4 3 2 4 4 6 1 2 2 4 2 1
result:
ok good
Test #17:
score: 0
Accepted
time: 1ms
memory: 3700kb
input:
112 633894500 167641802 339937464 844945998 269698167 432803430 591795000 657246871 31461268 443731992 6055837 817590568 986936937 160504265 528606045 304078549 879939770 433943593 793192949 260825675 586504056 752833202 507520443 563583937 733291184 91069383 362243954 908994979 651876073 944319771 ...
output:
2255 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 100 99 99 98 98 97 97 96 96 95 95 94 94 93 93 92 92 91 91 90 90 89 89 88 88 87 87 86 86 85 85 84 84 83 83 82 82 81 81 80 80 79 79 78 78 77 77 76 76 75 75 74 ...
result:
ok good
Test #18:
score: 0
Accepted
time: 13ms
memory: 3988kb
input:
475 513851595 939887761 535431296 196631717 780659274 904345731 960702202 930549847 783401281 700008841 764948141 408683368 580730549 656069530 812938319 239750378 509869370 458659369 111931962 953621825 247129346 579636113 197526284 860965062 770656291 712648065 719627561 994512440 776717865 721575...
output:
38843 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52 53 53 54 54 55 55 56 56 57 57 58 58 59 59 60 60 61 61 62 62 63 63 64 64 65 65 66 66 67 67 68 68 69 69 70 70 71 71 72 72 73 73 74 74 75 75 76 76 77 77 78 78 79 79 80 80 81 81 82 82 83 83 84 84 85 85 86 86 87 87 88 88 89 89 90 ...
result:
ok good
Test #19:
score: 0
Accepted
time: 14ms
memory: 4096kb
input:
511 692538384 450798311 689060453 338600390 623425233 806325979 214986187 65806871 160563193 565038083 651234761 686197630 390054944 16695632 976193125 348998588 109084352 295378672 886085460 966887442 454774074 452488333 950625229 873137681 490203016 343841646 453468043 199579268 254523368 59890754...
output:
41191 182 183 183 184 184 185 185 186 186 187 187 188 188 189 189 190 190 191 191 192 192 193 193 194 194 195 195 196 196 197 197 198 198 199 199 200 200 201 201 202 202 203 203 204 204 205 205 206 206 207 207 208 208 209 209 210 210 211 211 212 212 213 213 214 214 215 215 216 216 217 217 218 218 21...
result:
ok good
Test #20:
score: 0
Accepted
time: 83ms
memory: 8004kb
input:
6529 742820256 407098265 340024622 783273460 90005697 317112311 638332065 979785745 10427038 998056248 711257071 670551250 993934171 563965867 740492636 477441398 446620497 782019827 436884507 80766292 73444545 628480256 914515547 747218815 252222910 629497196 601718131 468014294 722599489 976762176...
output:
7165684 178 179 179 180 180 181 181 182 182 183 183 184 184 185 185 186 186 187 187 188 188 189 189 190 190 191 191 192 192 193 193 194 194 195 195 196 196 197 197 198 198 199 199 200 200 201 201 202 202 203 203 204 204 205 205 206 206 207 207 208 208 209 209 210 210 211 211 212 212 213 213 214 214 ...
result:
ok good
Test #21:
score: 0
Accepted
time: 170ms
memory: 26388kb
input:
49656 219729028 922565163 973184177 401278488 398509977 430136880 355221823 531198609 427159272 620342214 807056246 946023229 863329676 594785601 919885246 514268227 322020072 283161368 230524610 216372594 971966245 750604631 235100536 294361839 700788364 78618139 559468465 858060770 714675158 94275...
output:
410203271 47389 47388 47388 47387 47387 47386 47386 47385 47385 47384 47384 47383 47383 47382 47382 47381 47381 47380 47380 47379 47379 47378 47378 47377 47377 47376 47376 47375 47375 47374 47374 47373 47373 47372 47372 47371 47371 47370 47370 47369 47369 47368 47368 47367 47367 47366 47366 47365 47...
result:
ok good
Test #22:
score: 0
Accepted
time: 404ms
memory: 66392kb
input:
143669 948851763 284443096 962878315 551277661 202354141 381651768 403739560 826584405 363147562 724688034 670173153 506757091 350542543 655812219 60748415 522515497 41316518 689650777 261560751 125071377 69204090 943711167 165930454 226368865 920920481 458809698 371422646 842157114 24781050 7796296...
output:
3440983752 109079 109078 109078 109077 109077 109076 109076 109075 109075 109074 109074 109073 109073 109072 109072 109071 109071 109070 109070 109069 109069 109068 109068 109067 109067 109066 109066 109065 109065 109064 109064 109063 109063 109062 109062 109061 109061 109060 109060 109059 109059 10...
result:
ok good
Test #23:
score: 0
Accepted
time: 768ms
memory: 132932kb
input:
300000 331520194 609970309 604859193 816982812 725275830 848832553 819288112 916926379 193011613 436808431 53021469 38879580 455498144 387664917 824677349 258913448 967649601 259681227 672184202 936087138 579468080 716313897 121681024 568713806 32234516 783526144 244218286 423421704 256589283 747706...
output:
15016413052 206667 206666 206666 206665 206665 206664 206664 206663 206663 206662 206662 206661 206661 206660 206660 206659 206659 206658 206658 206657 206657 206656 206656 206655 206655 206654 206654 206653 206653 206652 206652 206651 206651 206650 206650 206649 206649 206648 206648 206647 206647 2...
result:
ok good
Test #24:
score: 0
Accepted
time: 744ms
memory: 133020kb
input:
300000 416161145 142034803 687753433 586352821 818995942 920991843 909428809 134612316 468444784 932090888 907047166 658380288 342653817 153914548 682888570 433423150 709429365 500294745 496103894 471710770 194392504 370866028 138123366 751752703 411914434 322763592 603804776 126892125 514141682 314...
output:
14986242618 51484 51485 51485 51486 51486 51487 51487 51488 51488 51489 51489 51490 51490 51491 51491 51492 51492 51493 51493 51494 51494 51495 51495 51496 51496 51497 51497 51498 51498 51499 51499 51500 51500 51501 51501 51502 51502 51503 51503 51504 51504 51505 51505 51506 51506 51507 51507 51508 ...
result:
ok good
Test #25:
score: 0
Accepted
time: 804ms
memory: 133184kb
input:
300000 63625989 165478863 263256412 91849262 716080542 237746804 700124328 748582752 398038374 654941747 955098470 199364646 300934431 149830580 970278026 465946242 69915827 304885370 96648834 808029699 733367012 541983596 633866224 993204257 599104305 776829056 49291455 688945398 434972599 79929872...
output:
15009354497 134185 134184 134184 134183 134183 134182 134182 134181 134181 134180 134180 134179 134179 134178 134178 134177 134177 134176 134176 134175 134175 134174 134174 134173 134173 134172 134172 134171 134171 134170 134170 134169 134169 134168 134168 134167 134167 134166 134166 134165 134165 1...
result:
ok good
Test #26:
score: 0
Accepted
time: 205ms
memory: 44796kb
input:
300000 2 2 1 2 1 1 2 1 1 1 1 2 2 2 1 1 2 1 2 2 1 1 1 2 2 2 2 1 1 2 2 2 1 2 2 1 1 1 2 1 2 1 2 1 2 2 1 1 2 2 2 2 1 2 2 1 1 2 2 1 1 2 2 2 1 2 1 2 1 1 2 2 1 2 2 2 2 1 2 1 2 1 1 2 2 1 1 1 1 1 2 2 1 2 1 2 1 2 2 1 1 2 1 2 1 2 2 2 2 1 1 1 2 1 1 1 1 2 1 2 2 1 2 1 2 1 2 1 1 1 2 1 1 2 1 1 2 2 2 1 1 1 1 2 2 2 2...
output:
25886863 3 2 5 4 4 3 6 5 33 32 36 35 35 34 34 33 37 36 36 35 35 34 38 37 37 36 36 35 40 39 39 38 38 37 37 36 42 41 41 40 40 39 44 43 43 42 42 41 41 40 47 46 46 45 45 44 44 43 43 42 42 41 48 47 47 46 46 45 45 44 44 43 43 42 53 52 52 51 51 50 50 49 49 48 48 47 47 46 46 45 45 44 44 43 56 55 55 54 54 53...
result:
ok good
Test #27:
score: 0
Accepted
time: 155ms
memory: 41692kb
input:
300000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000...
output:
0
result:
ok good
Test #28:
score: 0
Accepted
time: 148ms
memory: 27640kb
input:
176816 7 10 6 8 3 1 5 5 10 5 2 9 1 10 7 10 7 6 3 9 7 1 3 8 2 2 9 2 4 3 7 6 6 8 3 7 7 8 7 4 8 5 3 3 9 2 8 10 10 6 9 4 8 3 8 6 5 4 8 2 5 5 9 6 2 6 3 5 6 8 6 5 9 5 8 7 2 7 10 6 9 2 9 4 6 3 8 1 2 7 1 5 7 10 2 3 7 7 1 8 9 9 1 9 2 4 9 8 7 3 7 3 6 9 10 7 7 9 7 8 5 8 8 6 8 1 10 8 9 3 7 2 10 6 2 1 3 5 10 2 8...
output:
44397301 88 87 87 86 86 85 85 84 84 83 83 82 82 81 81 80 80 79 79 78 78 77 77 76 76 75 75 74 74 73 73 72 72 71 71 70 70 69 69 68 68 67 67 66 66 65 65 64 64 63 63 62 62 61 61 60 60 59 59 58 58 57 57 56 56 55 55 54 54 53 53 52 52 51 51 50 50 49 49 48 48 47 47 46 46 45 45 44 44 43 43 42 42 41 41 40 40 ...
result:
ok good
Test #29:
score: 0
Accepted
time: 211ms
memory: 34536kb
input:
231566 67 96 2 6 60 98 30 2 77 62 89 28 4 53 1 85 57 41 95 74 72 77 69 79 13 4 58 100 54 1 50 1 73 25 47 8 91 51 7 25 40 61 44 39 10 28 93 46 35 33 39 52 69 87 2 32 71 97 11 65 41 58 11 93 3 71 99 72 65 98 95 23 13 10 45 86 61 2 98 48 37 82 67 8 82 50 85 56 69 2 43 95 20 12 19 75 38 48 39 97 97 16 7...
output:
235926480 2165 2164 2164 2163 2163 2162 2162 2161 2161 2160 2160 2159 2159 2158 2158 2157 2157 2156 2156 2155 2155 2154 2154 2153 2153 2152 2152 2151 2151 2150 2150 2149 2149 2148 2148 2147 2147 2146 2146 2145 2145 2144 2144 2143 2143 2142 2142 2141 2141 2140 2140 2139 2139 2138 2138 2137 2137 2136 ...
result:
ok good
Test #30:
score: 0
Accepted
time: 110ms
memory: 10452kb
input:
39371 903 946 850 148 541 566 318 133 897 157 297 522 96 691 112 322 687 450 544 227 585 975 85 641 757 913 547 645 297 508 307 492 885 355 675 576 117 440 272 115 768 337 587 136 475 150 590 441 910 786 326 50 503 113 63 150 107 97 783 559 534 94 916 729 404 49 797 895 204 59 133 328 952 371 492 69...
output:
54149414 1022 1021 1021 1020 1020 1019 1019 1018 1018 1017 1017 1016 1016 1015 1015 1014 1014 1013 1013 1012 1012 1011 1011 1010 1010 1009 1009 1008 1008 1007 1007 1006 1006 1005 1005 1004 1004 1003 1003 1002 1002 1001 1001 1000 1000 999 999 998 998 997 997 996 996 995 995 994 994 993 993 992 992 99...
result:
ok good
Test #31:
score: 0
Accepted
time: 189ms
memory: 34664kb
input:
235958 14 3 11 7 6 14 2 17 7 9 5 18 48 5 6 34 6 12 7 18 7 13 2 7 3 5 10 10 1 2 30 3 3 5 7 17 15 16 9 2 5 8 9 16 2 57 8 14 29 2 5 3 5 8 26 5 5 11 25 2 1 3 1 4 5 9 9 23 6 13 7 18 1 2 1 5 8 16 10 13 3 11 8 2 2 8 2 13 4 2 2 9 58 4 1 18 4 23 23 16 7 4 3 5 21 1 20 6 4 25 4 4 27 19 3 1 5 6 14 2 10 5 15 10 ...
output:
112071301 29 28 28 27 27 26 26 25 61 60 60 59 59 58 58 57 57 56 56 55 55 54 54 53 53 52 52 51 51 50 50 49 49 48 48 47 47 46 46 45 45 44 44 43 43 42 42 41 41 40 40 39 39 38 38 37 37 36 36 35 63 62 62 61 61 60 60 59 59 58 58 57 57 56 56 55 55 54 54 53 53 52 52 51 51 50 50 49 49 48 48 47 47 46 46 45 45...
result:
ok good
Test #32:
score: 0
Accepted
time: 180ms
memory: 26628kb
input:
168818 20 120 38 1 33 24 2 117 89 163 206 130 159 107 80 18 49 81 12 148 215 33 118 70 212 273 200 186 381 11 87 119 27 114 18 98 13 5 7 19 8 233 5 56 5 202 52 12 167 42 3 22 99 252 6 70 58 157 113 118 32 19 58 93 55 4 75 114 100 110 23 61 32 47 111 78 21 40 29 53 34 17 8 22 256 60 214 75 33 44 77 4...
output:
197324279 411 410 410 409 409 408 408 407 407 406 406 405 405 404 404 403 403 402 402 401 401 400 400 399 399 398 398 397 397 396 396 395 395 394 394 393 393 392 392 391 391 390 390 389 389 388 388 387 387 386 386 385 385 384 384 383 383 382 382 381 381 380 380 379 379 378 378 377 377 376 376 375 37...
result:
ok good
Test #33:
score: 0
Accepted
time: 243ms
memory: 35996kb
input:
232968 551 666 2798 73 92 153 695 365 665 1892 246 5 622 1023 306 517 659 184 22 4253 903 1677 704 489 176 825 62 690 932 595 373 1332 110 2472 5060 2962 2168 476 2151 258 650 47 1387 743 279 734 654 1034 319 605 583 743 1071 2368 2453 343 2920 903 283 2267 247 1987 2435 226 2848 1901 627 332 795 24...
output:
1039756443 1390 1389 1389 1388 1388 1387 1387 1386 1386 1385 1385 1384 1384 1383 1383 1382 1382 1381 1381 1380 1380 1379 1379 1378 1378 1377 1377 1376 1376 1375 1375 1374 1374 1373 1373 1372 1372 1371 1371 1370 1370 1369 1369 1368 1368 1367 1367 1366 1366 1365 1365 1364 1364 1363 1363 1362 1362 1361...
result:
ok good
Test #34:
score: 0
Accepted
time: 330ms
memory: 39788kb
input:
195773 5302 14362 3699 11204 9432 5223 874 3176 9560 12580 11109 5568 3112 16403 4984 9107 14921 2825 26911 1114 12676 8934 7553 5707 4624 261 7174 3969 7229 995 12560 3149 15395 361 2741 17350 13096 692 5663 4382 1787 5225 5789 38682 5639 142 2026 13175 56693 5144 8186 7674 8151 20929 3120 19942 45...
output:
2400974864 16995 16994 16994 16993 16993 16992 16992 16991 16991 16990 16990 16989 16989 16988 16988 16987 16987 16986 16986 16985 16985 16984 16984 16983 16983 16982 16982 16981 16981 16980 16980 16979 16979 16978 16978 16977 16977 16976 16976 16975 16975 16974 16974 16973 16973 16972 16972 16971 1...
result:
ok good
Test #35:
score: 0
Accepted
time: 100ms
memory: 10788kb
input:
43310 485 488 505 499 514 506 516 504 509 494 485 485 461 515 473 490 497 506 514 486 498 499 485 476 511 509 504 515 473 503 504 499 519 503 497 490 518 493 511 513 527 517 521 500 486 501 527 489 497 490 481 509 485 519 490 505 512 487 513 503 498 505 468 491 501 511 508 494 486 512 498 483 491 50...
output:
17692669 25035 25036 25036 25037 25037 25038 25038 25039 25039 25040 25040 25041 25041 25042 25042 25043 25043 25044 25044 25045 25045 25046 25046 25047 25047 25048 25048 25049 25049 25050 25050 25051 25051 25052 25052 25053 25053 25054 25054 25055 25055 25056 25056 25057 25057 25058 25058 25059 250...
result:
ok good
Test #36:
score: 0
Accepted
time: 195ms
memory: 29688kb
input:
194102 50131 49939 49866 50269 49793 49984 49901 50093 49948 49752 49932 49959 50080 50115 50096 50195 49844 49922 49846 50088 49963 49868 49949 50004 50001 49904 49998 50198 50238 50052 50106 49908 49952 49941 49984 49841 49833 49921 50056 49848 49782 50294 50024 49710 50097 50094 50147 50060 50091...
output:
535599810 84021 84022 84022 84023 84023 84024 84024 84025 84025 84026 84026 84027 84027 84028 84028 84029 84029 84030 84030 84031 84031 84032 84032 84033 84033 84034 84034 84035 84035 84036 84036 84037 84037 84038 84038 84039 84039 84040 84040 84041 84041 84042 84042 84043 84043 84044 84044 84045 84...
result:
ok good
Test #37:
score: 0
Accepted
time: 76ms
memory: 7428kb
input:
7271 4997632 4998700 5002258 4999918 4997849 4999632 5002192 5001791 4999609 4998611 5002424 5001283 5001105 5000026 4999812 4999613 5001085 5000628 4998722 4999207 5000423 4998174 4998956 4999616 5000560 5000759 4999883 5000452 5002041 5000568 5003774 4995060 4999806 5001118 5001118 5001143 4998699...
output:
7152021 6506 6505 6505 6504 6504 6503 6503 6502 6502 6501 6501 6500 6500 6499 6499 6498 6498 6497 6497 6496 6496 6495 6495 6494 6494 6493 6493 6492 6492 6491 6491 6490 6490 6489 6489 6488 6488 6487 6487 6486 6486 6485 6485 6484 6484 6483 6483 6482 6482 6481 6481 6480 6480 6479 6479 6478 6478 6477 64...
result:
ok good
Test #38:
score: 0
Accepted
time: 234ms
memory: 44440kb
input:
300000 2 2 1 1 2 1 1 2 2 2 1 2 1 2 1 1 1 1 1 1 2 1 1 2 1 1 2 1 1 2 2 2 2 1 2 1 2 2 2 2 2 1 2 1 1 2 2 2 1 2 2 2 2 2 1 1 2 2 1 1 1 2 2 2 1 1 2 1 2 1 1 1 2 2 1 1 1 1 2 1 2 1 2 2 2 2 2 2 1 2 2 1 1 2 1 2 1 1 1 1 2 1 2 1 2 2 2 1 2 2 1 2 2 1 2 1 1 1 2 1 1 2 2 2 2 2 1 1 2 2 1 1 1 1 2 2 2 1 2 1 2 1 2 1 2 1 1...
output:
57845874 3 2 6 5 7 6 11 10 10 9 9 8 8 7 13 12 12 11 11 10 10 9 15 14 14 13 13 12 12 11 16 15 15 14 14 13 17 16 16 15 18 17 22 21 23 22 25 24 24 23 26 25 25 24 28 27 27 26 26 25 29 28 28 27 27 26 34 33 33 32 32 31 31 30 30 29 29 28 36 35 35 34 34 33 33 32 32 31 31 30 42 41 41 40 40 39 39 38 38 37 37 ...
result:
ok good
Test #39:
score: 0
Accepted
time: 1ms
memory: 3776kb
input:
100 4 87 26 88 67 39 23 63 85 31 14 89 100 6 66 47 9 15 83 65 94 24 97 30 90 78 75 49 55 55 88 17 55 74 80 94 96 22 20 46 89 36 63 71 99 26 37 85 20 65 74 88 18 34 36 39 97 90 12 99 77 2 85 50 65 55 14 76 33 97 31 18 52 59 38 39 10 100 3 9 12 65 84 28 41 8 38 16 4 71 66 58 70 70 83 98 77 48 1 1 4 87...
output:
0
result:
ok good
Test #40:
score: 0
Accepted
time: 442ms
memory: 51468kb
input:
300000 3510 109 8532 4953 4212 4287 288 6752 2547 2477 10403 23835 24740 6351 11012 17052 3052 28948 5420 28157 26745 4075 27407 6857 12543 17382 10752 17794 9895 27509 23933 29329 12170 13620 8967 9018 18540 317 6179 207 8022 8239 13903 11277 13499 28190 24090 13577 2795 21398 9884 27429 20882 1976...
output:
7358593880 69374 69373 69373 69372 69372 69371 69371 69370 69370 69369 69369 69368 69368 69367 69367 69366 69366 69365 69365 69364 69364 69363 69363 69362 69362 69361 69361 69360 69360 69359 69359 69358 69358 69357 69357 69356 69356 69355 69355 69354 69354 69353 69353 69352 69352 69351 69351 69350 6...
result:
ok good
Test #41:
score: 0
Accepted
time: 211ms
memory: 51092kb
input:
300000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 11 11 11 11 11 11 11 11 11 12 12 12 12 12 13 13 13 13 13 13 13 13 14 14 14 14 14 14 15 15 15...
output:
44998350640 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52 53 53 54 54 55 55 56 56 57 57 58 58 59 59 60 60 61 61 62 ...
result:
ok good
Test #42:
score: 0
Accepted
time: 213ms
memory: 50928kb
input:
300000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 29999 29999 29999 29999 29999 29999 29999 29999 29999 29998 29998 29998 29998 29998 29998 29998 29997 29997 29997 29997 29997 29997 29997 29996 29996 29996 29996 29996 29996 29996 29996 29996 29996 29996 29996 29996 29996 29996...
output:
44998347970 299986 299985 299985 299984 299984 299983 299983 299982 299982 299981 299981 299980 299980 299979 299979 299978 299978 299977 299977 299976 299976 299975 299975 299974 299974 299973 299973 299972 299972 299971 299971 299970 299970 299969 299969 299968 299968 299967 299967 299966 299966 2...
result:
ok good
Test #43:
score: 0
Accepted
time: 365ms
memory: 51380kb
input:
300000 19672 8950 23909 24951 28567 27869 26008 28228 26386 14895 16933 9274 126 9775 26676 351 24407 21498 7594 5537 1233 20507 14785 22396 14060 6360 1560 12033 23426 18978 28983 14093 12532 6607 11002 4584 16311 28864 28349 3566 10622 27973 14784 13581 25877 19888 27730 25763 2402 29804 16834 272...
output:
22488871204 45504 45503 45503 45502 45502 45501 45501 45500 45500 45499 45499 45498 45498 45497 45497 45496 45496 45495 45495 45494 45494 45493 45493 45492 45492 45491 45491 45490 45490 45489 45489 45488 45488 45487 45487 45486 45486 45485 45485 45484 45484 45483 45483 45482 45482 45481 45481 45480 ...
result:
ok good
Test #44:
score: 0
Accepted
time: 385ms
memory: 51400kb
input:
300000 23753 3887 28899 6050 25836 19213 12501 6087 6494 6511 5634 4213 8368 26766 10517 886 29785 21144 13177 7246 28535 8442 10770 20409 23538 8496 6671 13794 22582 26076 4761 21624 1974 1416 17685 10559 27335 26950 7893 7066 17000 7898 14529 6739 10443 417 24046 8210 29437 4556 28410 18871 98 265...
output:
22455006608 266099 266100 266100 266101 266101 266102 266102 266103 266103 266104 266104 266105 266105 266106 266106 266107 266107 266108 266108 266109 266109 266110 266110 266111 266111 266112 266112 266113 266113 266114 266114 266115 266115 266116 266116 266117 266117 266118 266118 266119 266119 2...
result:
ok good
Test #45:
score: 0
Accepted
time: 271ms
memory: 51396kb
input:
300000 1 1 1 1 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 3 3 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 10 10 10 10 11 11 11 11 11 11 11 11 11 11 12 12 12 12 12 12 12 12 12 12 12 13 13 13 13 13 13 ...
output:
22487598571 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52 53 53 54 54 55 55 56 56 57 5...
result:
ok good
Test #46:
score: 0
Accepted
time: 272ms
memory: 51472kb
input:
300000 30000 30000 30000 30000 30000 30000 30000 30000 30000 29999 29999 29999 29999 29999 29999 29999 29999 29999 29999 29998 29998 29998 29998 29998 29998 29998 29998 29998 29998 29998 29998 29998 29998 29997 29997 29997 29997 29997 29997 29997 29997 29997 29996 29996 29996 29996 29996 29996 29996...
output:
22518298944 299991 299990 299990 299989 299989 299988 299988 299987 299987 299986 299986 299985 299985 299984 299984 299983 299983 299982 299982 299981 299981 299980 299980 299979 299979 299978 299978 299977 299977 299976 299976 299975 299975 299974 299974 299973 299973 299972 299972 299971 299971 2...
result:
ok good
Test #47:
score: 0
Accepted
time: 1ms
memory: 3560kb
input:
3 1 1 2 2 1 1
output:
2 2 3 1 2
result:
ok good
Test #48:
score: 0
Accepted
time: 1ms
memory: 3532kb
input:
3 2 1 1 1 1 2
output:
2 2 1 3 2
result:
ok good
Test #49:
score: 0
Accepted
time: 0ms
memory: 3484kb
input:
3 2 2 1 1 2 2
output:
2 3 2 2 1
result:
ok good
Test #50:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
3 1 2 2 2 2 1
output:
2 1 2 2 3
result:
ok good