QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#633659 | #6146. 取模 | propane | 100 ✓ | 38ms | 5884kb | C++20 | 1.1kb | 2024-10-12 15:58:35 | 2024-10-12 15:58:36 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
using LL = long long;
int main(){
#ifdef LOCAL
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int n;
cin >> n;
vector<int> a(n);
for(int i = 0; i < n; i++) cin >> a[i];
sort(a.begin(), a.end());
int ans = 0;
for(int i = n - 1; i >= 0; i--){
if (a[i] - 1 <= ans){
cout << ans << '\n';
return 0;
}
vector<int> b;
for(int j = 0; j < n; j++){
if (i != j){
b.push_back(a[j] % a[i]);
}
}
sort(b.begin(), b.end());
ans = max(ans, (b[n - 3] + b[n - 2]) % a[i]);
for(int j = 0, k = b.size() - 1; j < b.size(); j++){
while(k >= 0 and b[j] + b[k] >= a[i]) k--;
int t = k;
if (t == j) t--;
if (t >= 0) ans = max(ans, b[j] + b[t]);
}
}
cout << ans << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Final Tests
Test #1:
score: 5
Accepted
time: 1ms
memory: 3784kb
input:
100 50440675 50658932 51463847 52125314 52233705 52661152 52819748 52829262 55257782 55289721 55458389 56354866 56698138 56909193 57519592 57689074 58569445 59047218 59073314 59208822 60180578 60898252 60906480 61020492 61112893 61154204 62030669 62774823 62932980 62956613 63914763 64012869 65004071...
output:
97377230
result:
ok 1 number(s): "97377230"
Test #2:
score: 5
Accepted
time: 1ms
memory: 3792kb
input:
100 50915253 51143045 51380924 51567338 53673346 55199602 55648032 56086289 56389475 57577006 57917116 58699040 59299400 59565661 59602985 59772428 59995803 60165294 61002600 61448248 62830056 62849028 63050402 63722375 63820561 63867573 65158143 65403988 65560675 67159718 67526802 69185146 70783326...
output:
98479984
result:
ok 1 number(s): "98479984"
Test #3:
score: 5
Accepted
time: 1ms
memory: 3788kb
input:
100 50096789 50264419 50513330 54089782 54222630 55073965 55789833 56585168 57405656 58248992 58531474 58742547 59251986 59678914 60001699 60075743 60767006 60975222 61857975 62768698 63104150 63345933 63980952 65066791 65212019 65222039 65577410 65788679 66974822 67484568 67558181 68383199 69661446...
output:
97504335
result:
ok 1 number(s): "97504335"
Test #4:
score: 5
Accepted
time: 1ms
memory: 3856kb
input:
100 50076851 50432788 50626919 50666251 50920743 50991587 51385024 51866238 52471960 53730850 54115916 54756923 57659512 58595599 59780977 60197145 60394261 61572681 62423567 62764785 63319964 63361478 63679787 64069390 64656761 64714696 65407867 65614383 66823134 67484825 67862880 68321682 68495215...
output:
97818080
result:
ok 1 number(s): "97818080"
Test #5:
score: 5
Accepted
time: 1ms
memory: 3860kb
input:
100 50426341 51320484 51383678 51436549 51619677 52701032 52929753 52966575 53925700 54612568 54764877 54825600 54829565 55149114 55358038 55763436 56815727 56913071 57220358 59496032 59783531 60174909 60446493 60469737 60776241 61620380 61812651 62819241 62846841 62863305 63105159 63530664 64363960...
output:
98923751
result:
ok 1 number(s): "98923751"
Test #6:
score: 5
Accepted
time: 1ms
memory: 3620kb
input:
100 50630478 51205847 51393664 52385183 53091123 53825823 53843426 53854358 53983542 54210981 54229783 55457564 55510182 55730580 55853796 55896680 56122312 56770910 57235774 57870361 58279079 58370218 59244437 59534110 59855853 60077162 60468860 60727861 61215822 61345827 62144884 62178038 62191331...
output:
99210746
result:
ok 1 number(s): "99210746"
Test #7:
score: 5
Accepted
time: 1ms
memory: 3900kb
input:
3000 50012095 50012368 50028802 50068549 50070331 50074916 50095436 50123734 50130580 50170913 50172205 50175901 50175975 50181366 50196403 50209408 50215609 50270177 50318926 50330089 50389093 50390284 50407951 50417369 50434483 50465573 50493644 50498559 50511523 50522728 50523794 50535454 5056202...
output:
99949147
result:
ok 1 number(s): "99949147"
Test #8:
score: 5
Accepted
time: 1ms
memory: 3612kb
input:
3000 50019163 50027237 50035527 50042879 50047917 50084497 50090718 50093078 50114082 50125639 50221843 50274300 50312926 50327478 50343620 50345560 50361665 50376144 50378748 50431807 50444942 50449537 50479215 50491350 50495064 50500085 50509251 50546705 50548340 50566116 50590661 50627081 5062843...
output:
99980210
result:
ok 1 number(s): "99980210"
Test #9:
score: 5
Accepted
time: 1ms
memory: 3576kb
input:
3000 50156754 50175762 50192921 50224708 50257159 50263796 50302534 50321557 50334380 50351898 50363253 50368912 50389006 50391577 50404635 50404690 50433181 50438507 50469445 50477281 50478396 50491087 50492124 50503795 50527048 50537990 50592263 50600161 50619060 50653101 50682080 50687735 5072079...
output:
99969830
result:
ok 1 number(s): "99969830"
Test #10:
score: 5
Accepted
time: 1ms
memory: 3668kb
input:
2999 50011761 50022546 50028858 50071268 50082775 50093277 50097210 50149085 50151148 50173947 50182580 50187050 50197298 50239950 50250548 50250769 50261714 50273607 50313566 50314448 50314716 50317745 50318467 50320961 50323987 50330114 50331035 50372565 50407235 50427992 50440587 50447351 5044988...
output:
99993202
result:
ok 1 number(s): "99993202"
Test #11:
score: 5
Accepted
time: 1ms
memory: 3908kb
input:
3000 50002366 50035319 50057460 50070194 50081906 50090198 50090459 50093735 50127760 50134998 50160158 50162408 50171685 50189037 50197858 50255913 50279055 50284457 50294033 50299187 50300170 50301838 50341487 50360654 50376925 50404340 50423718 50429486 50443862 50449032 50451861 50488813 5050033...
output:
99941901
result:
ok 1 number(s): "99941901"
Test #12:
score: 5
Accepted
time: 1ms
memory: 3608kb
input:
3000 50004901 50010842 50018008 50121698 50145058 50152278 50152564 50162138 50169560 50182054 50182193 50186770 50193652 50219938 50222106 50223435 50261438 50265404 50270891 50304437 50310811 50315284 50336196 50336914 50341622 50398039 50399015 50449257 50459491 50473508 50488979 50520709 5053337...
output:
99936509
result:
ok 1 number(s): "99936509"
Test #13:
score: 5
Accepted
time: 28ms
memory: 5808kb
input:
199617 50000436 50000710 50000754 50000874 50001405 50001491 50001594 50001914 50002117 50002278 50002322 50002392 50002519 50002561 50002823 50002825 50002932 50003029 50003106 50003270 50003294 50003785 50003794 50003842 50004289 50004363 50004462 50004542 50006185 50006256 50006615 50008055 50008...
output:
99999085
result:
ok 1 number(s): "99999085"
Test #14:
score: 5
Accepted
time: 31ms
memory: 5804kb
input:
199609 50000006 50000253 50000527 50000602 50000786 50001617 50001920 50002348 50002628 50002750 50003601 50003641 50003654 50003790 50004089 50004198 50004243 50004354 50004502 50004794 50005265 50005573 50005652 50005871 50006027 50006640 50006655 50007332 50008315 50008499 50008678 50008766 50008...
output:
99999649
result:
ok 1 number(s): "99999649"
Test #15:
score: 5
Accepted
time: 31ms
memory: 5864kb
input:
199623 50000633 50000791 50001098 50001115 50001450 50001473 50001474 50002361 50002947 50003383 50004047 50004406 50004546 50005340 50005517 50005535 50005668 50005718 50005807 50005829 50006287 50006334 50006429 50006474 50006959 50007025 50007282 50007778 50007928 50008181 50008714 50008747 50009...
output:
99998934
result:
ok 1 number(s): "99998934"
Test #16:
score: 5
Accepted
time: 31ms
memory: 5884kb
input:
199599 50000008 50000099 50000189 50000702 50000890 50001129 50001415 50001534 50001890 50002431 50003033 50003181 50003242 50003271 50003323 50003494 50003624 50003650 50003716 50003788 50004001 50004114 50004186 50004455 50004737 50004790 50005041 50005728 50006028 50006307 50006313 50006415 50006...
output:
99999726
result:
ok 1 number(s): "99999726"
Test #17:
score: 5
Accepted
time: 27ms
memory: 5864kb
input:
199610 50000117 50000839 50002703 50003677 50003678 50003872 50003989 50004010 50004254 50004608 50004649 50004727 50005254 50005487 50005641 50005978 50006083 50006116 50006341 50006581 50006689 50006929 50006998 50007500 50007785 50008138 50008854 50009410 50009555 50009664 50010045 50010484 50010...
output:
99998213
result:
ok 1 number(s): "99998213"
Test #18:
score: 5
Accepted
time: 31ms
memory: 5748kb
input:
199594 50000248 50000340 50000908 50000941 50001074 50001186 50001219 50001354 50001366 50001958 50002240 50002398 50002684 50002868 50003333 50003497 50003780 50003906 50003913 50004138 50004354 50004825 50004986 50005332 50005483 50005507 50005566 50005573 50005724 50005959 50006506 50006615 50007...
output:
99999776
result:
ok 1 number(s): "99999776"
Test #19:
score: 5
Accepted
time: 27ms
memory: 5780kb
input:
199614 50000010 50000223 50000267 50000276 50000302 50000617 50000885 50000907 50000961 50000973 50000982 50001208 50001226 50001488 50001793 50002069 50002261 50002309 50002588 50002753 50003105 50003289 50003440 50003639 50003698 50003874 50003963 50004134 50004593 50004778 50005021 50005076 50005...
output:
99999139
result:
ok 1 number(s): "99999139"
Test #20:
score: 5
Accepted
time: 38ms
memory: 5816kb
input:
199632 50000088 50000234 50000259 50000920 50001535 50001617 50002026 50002091 50002274 50002348 50002466 50002584 50002596 50002862 50002969 50003005 50003303 50003642 50003691 50003965 50004270 50004376 50004450 50004470 50005615 50006182 50006257 50006523 50007008 50007146 50007187 50007623 50007...
output:
99998888
result:
ok 1 number(s): "99998888"