QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#620698 | #7750. Revenge on My Boss | warner1129 | WA | 398ms | 8540kb | C++20 | 2.6kb | 2024-10-07 20:30:01 | 2024-10-07 20:30:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
template<class F, class S>
ostream &operator<<(ostream &s, const pair<F, S> &v) {
s << "(" << v.first << ", " << v.second << ")";
return s;
}
template<ranges::range T> requires (!is_convertible_v<T, string_view>)
istream &operator>>(istream &s, T &&v) {
for (auto &&x : v) s >> x;
return s;
}
template<ranges::range T> requires (!is_convertible_v<T, string_view>)
ostream &operator<<(ostream &s, T &&v) {
for (auto &&x : v) s << x << ' ';
return s;
}
#ifdef LOCAL
template<class... T> void dbg(T... x) {
char e{};
((cerr << e << x, e = ' '), ...);
}
#define debug(x...) dbg(#x, '=', x, '\n')
#else
#define debug(...) ((void)0)
#endif
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define ff first
#define ss second
template<class T> inline constexpr T inf = numeric_limits<T>::max() / 2;
bool chmin(auto &a, auto b) { return (b < a and (a = b, true)); }
bool chmax(auto &a, auto b) { return (a < b and (a = b, true)); }
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128;
using u128 = unsigned __int128;
constexpr i64 mod = 998244353;
void solve() {
int n;
cin >> n;
vector<i64> A(n), B(n), C(n), D(n);
for (int i = 0; i < n; i++) {
cin >> A[i] >> B[i] >> C[i];
D[i] = A[i] - B[i];
}
const i64 Bsum = reduce(all(B), 0LL);
vector<pair<i64, i64>> pa(n);
vector<int> ord(n);
iota(all(ord), 0);
auto check = [&](i64 P) -> bool {
for (int i = 0; i < n; i++) {
pa[i] = {D[i], P / C[i] - B[i] - Bsum};
}
sort(all(ord), [&](int i, int j) {
auto a = pa[i];
auto b = pa[j];
return min(a.ss - a.ff, b.ss - a.ff - b.ff) > min(b.ss - b.ff, a.ss - a.ff - b.ff);
});
i64 sum = 0;
for (auto i : ord) {
auto [a, b] = pa[i];
sum += a;
if (sum > b) {
return false;
}
}
return true;
};
i64 ans = *ranges::partition_point(views::iota(0LL, (i64)1E18),
[&](i64 x) {
return !check(x);
});
check(ans);
for (int x : ord) {
cout << x + 1 << " \n"[x == ord.back()];
}
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
input:
2 4 1 1 4 5 1 5 1 9 1 9 8 1 9 3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 8 3 2 7
output:
3 1 2 4 3 8 4 2 5 9 7 1 6
result:
ok correct
Test #2:
score: 0
Accepted
time: 321ms
memory: 8368kb
input:
1 100000 581297 102863 1 742857 42686 1 676710 233271 1 443055 491162 1 442056 28240 1 769277 331752 1 8608 369730 1 495112 525554 1 787449 938154 1 441186 850694 1 84267 925450 1 740811 32385 1 834021 37680 1 257878 564126 1 90618 914340 1 239641 463103 1 40687 343062 1 587737 458554 1 103684 48666...
output:
70717 6151 48237 28851 35679 19561 94252 73342 13089 34865 69194 82763 50242 22597 3745 24913 97923 53671 77581 47428 82224 93567 61401 50007 4886 54152 28731 91278 99937 6691 26840 6048 46204 66044 60735 44469 20513 45842 18701 46818 27203 9261 50507 8020 72391 54368 86201 18839 64763 61758 40939 3...
result:
ok correct
Test #3:
score: 0
Accepted
time: 327ms
memory: 8372kb
input:
1 99999 30245 831673 1 495617 185056 1 53028 422589 1 503558 778900 1 636981 480008 1 966864 78785 1 644954 303138 1 153080 225499 1 876411 832264 1 758904 549009 1 945000 441995 1 83780 789901 1 883282 832556 1 300776 548075 1 806599 108342 1 354979 831549 1 152110 819163 1 613891 812479 1 856259 6...
output:
42779 26176 16432 93736 36110 21022 69840 33300 88899 48735 24934 97468 58044 16598 54398 41611 25297 90410 54385 14754 38513 7374 40518 45724 3741 95478 36354 5270 92123 87433 5901 57489 42968 40570 60847 61715 65894 68944 27887 3727 38578 14748 15072 79314 41234 42830 79639 35429 60443 63782 12370...
result:
ok correct
Test #4:
score: 0
Accepted
time: 325ms
memory: 8428kb
input:
1 100000 361850 684411 2 188930 167748 2 676274 449963 1 970095 784305 1 412379 854673 1 208323 612179 1 296548 633970 1 560983 633064 2 848966 248363 2 741057 340814 1 393854 435721 2 302707 834494 1 229770 235051 2 875992 747523 2 314215 448795 1 531181 809914 2 786505 95721 1 86557 773136 1 44527...
output:
16321 7131 35939 39108 40409 52183 74664 70501 56736 85313 78033 67062 11374 28893 29910 76382 77675 16590 14329 99654 33902 81051 93812 47118 54934 27805 77685 57504 62353 47016 36321 65709 30222 17782 92966 93722 32969 69339 20699 31143 29231 20833 32593 17020 77014 2193 20753 96742 16406 11108 56...
result:
ok correct
Test #5:
score: 0
Accepted
time: 326ms
memory: 8484kb
input:
1 99999 810798 413222 2 974394 310117 1 987184 606577 2 30598 6635 1 607304 306441 1 438614 583404 1 932894 375890 1 994760 333009 2 937928 950984 2 58774 6426 1 287291 728073 1 421484 592009 1 470520 62631 1 918891 764176 2 997492 642796 1 679223 178361 2 865224 571822 2 112711 192469 1 165146 9387...
output:
38004 71563 34947 26525 22330 44909 47503 52297 78657 28797 29991 22680 7929 68438 15865 70932 27655 90081 30923 61265 20749 31006 35033 64820 20963 86257 21420 27746 3451 43480 36392 44360 16524 76128 8052 60705 72335 52826 82386 88960 8813 60213 12369 84977 96785 82723 23228 1372 34613 67012 54683...
result:
ok correct
Test #6:
score: 0
Accepted
time: 327ms
memory: 8396kb
input:
1 100000 142404 976360 1 924602 517001 3 610429 601247 2 529839 44745 3 606894 456914 2 488586 84093 1 360297 674019 1 435366 740573 3 943187 591275 3 8223 87831 2 703441 689095 1 673115 893499 3 817008 689318 2 237211 187815 1 472404 15953 2 822721 932534 2 275427 591484 3 393890 928933 1 11058 141...
output:
51206 37611 59015 50700 80703 52328 53240 43032 8346 8263 41296 64851 47024 78344 80432 99788 79216 80112 84718 81292 91031 58261 72331 98859 85353 71212 34320 28981 4231 54595 26732 77344 6558 79986 1230 64802 4053 35487 35001 47208 53390 6142 58146 9701 11407 53054 48744 52885 2922 93682 94826 636...
result:
ok correct
Test #7:
score: 0
Accepted
time: 330ms
memory: 8408kb
input:
1 99999 815544 929362 2 644659 659371 3 954043 790565 3 398854 42883 3 577627 875978 2 718877 831126 1 996643 640131 2 869143 249030 3 32149 261192 1 325941 753442 3 372686 238344 2 48789 426822 2 57757 260002 1 280109 237173 3 931489 242658 2 970763 300980 2 578337 100288 1 611532 282858 3 506737 2...
output:
27161 35747 25296 34165 9717 57726 57073 11785 24054 83782 88554 68057 42695 23849 49568 78850 8501 69293 52754 11183 39393 98733 35177 37567 85341 22705 9930 96866 82802 47796 9996 57550 29112 27373 52932 83741 39761 26412 12546 99295 22521 45367 72274 77249 22609 44764 11050 29507 28236 24580 4570...
result:
ok correct
Test #8:
score: 0
Accepted
time: 330ms
memory: 8372kb
input:
1 100000 179854 525204 1 403379 866255 3 544585 817939 4 832686 337889 3 577217 283347 1 960336 331815 3 424045 970964 1 309749 591186 4 37408 677291 2 308093 545247 1 45732 199365 1 267715 728311 2 404245 919393 4 855325 436620 1 406400 774600 3 146965 279345 3 955837 376846 3 860006 276218 2 28724...
output:
24436 23350 14823 6635 16186 28793 85545 28010 65377 49593 9096 36992 62631 55712 98568 36492 47289 43010 3738 84762 70128 48544 57069 75781 59468 17061 39547 97907 7290 48134 29862 84143 19385 42718 49107 41621 94075 30404 65165 61273 78021 98586 89053 17836 39470 53504 98341 37199 90866 20337 9343...
result:
ok correct
Test #9:
score: 0
Accepted
time: 321ms
memory: 8368kb
input:
1 99999 628802 478207 4 156140 784432 3 920902 198745 3 925893 336026 4 772142 702412 2 190627 335745 3 93095 937076 4 710822 356539 2 126370 604104 4 625811 243562 3 714977 524422 2 386493 485827 2 677699 522781 4 898224 453274 1 89677 777113 3 262303 647792 3 291451 852947 2 886160 662847 1 848327...
output:
25476 82833 20708 62196 65199 34417 31863 24519 6410 2660 86721 49138 41559 14233 14538 12861 77995 81983 14766 34516 89431 97096 88505 83091 38565 74389 94338 68659 85344 5885 21302 17145 57922 53773 76261 38160 50466 83035 84330 45236 77809 51690 49927 6715 43442 92483 55111 97458 84347 80388 4440...
result:
ok correct
Test #10:
score: 0
Accepted
time: 331ms
memory: 8376kb
input:
1 100000 993111 41344 2 849452 991316 3 287252 969223 4 392430 565624 3 547540 852885 3 240598 836434 5 520498 11013 2 151428 698695 1 98926 987499 3 607963 259559 2 131127 518148 5 638124 530420 3 991483 116764 5 440736 876913 1 564589 309054 1 438505 593453 5 701654 872609 4 391530 399311 5 628832...
output:
40304 73884 46665 34832 83244 13265 71577 34416 81702 34262 55470 14854 96718 20687 75463 16459 34149 34475 8088 30861 77981 72514 92859 39810 55233 80930 35735 85535 89142 73204 61946 48999 88803 32652 61389 33091 39964 64315 41786 22045 69345 85883 21081 60246 54103 75958 66900 11113 17122 41787 3...
result:
ok correct
Test #11:
score: 0
Accepted
time: 322ms
memory: 8480kb
input:
1 99999 633547 770155 1 634916 133686 5 855058 382733 4 485637 596466 2 742466 271949 3 470889 583467 1 156844 977125 2 585205 464048 5 187887 690121 3 892977 925171 2 57268 34693 4 981093 255232 2 232232 977047 5 516338 893566 4 247866 311567 3 586547 994603 5 4565 348710 5 417684 977428 3 124510 7...
output:
48240 97152 38149 92052 85126 48738 420 86878 1608 77274 25520 16300 85538 61415 87215 9020 23040 6708 82083 15814 66859 99499 16595 23692 38022 28113 27468 68026 15427 8746 33174 14077 72913 80575 26563 66510 41324 17717 35068 39018 73663 45534 19933 82609 30013 16591 13958 58164 4681 66871 61356 1...
result:
ok correct
Test #12:
score: 0
Accepted
time: 330ms
memory: 8460kb
input:
1 100000 997857 590189 5 552421 307866 1 221408 153211 4 952174 826064 4 742055 646614 4 712348 116860 2 808438 307957 5 250004 806205 1 193147 297708 2 875130 941168 5 473418 995714 5 975828 556721 3 578721 379543 1 834658 317206 4 722778 876212 3 730045 972968 6 414768 657972 1 633455 746596 6 970...
output:
58367 96255 27046 51517 62990 14996 43792 8080 70637 88785 56968 29155 30934 51774 59548 29427 90925 70372 58953 41857 33191 96145 17321 23404 87318 1596 46324 13075 9593 11090 26264 56726 77126 83979 64736 94161 65026 25548 5002 62346 36677 33190 44945 17805 87787 14720 15278 41786 55909 91963 1146...
result:
ok correct
Test #13:
score: 0
Accepted
time: 326ms
memory: 8436kb
input:
1 99999 414101 318999 4 305181 450235 4 789213 599425 5 12677 889610 6 936981 98382 2 942639 831190 3 444784 241365 4 683780 538854 3 314812 329 6 192848 447995 3 142664 320771 6 384205 90044 2 595278 174418 6 877557 109667 2 181863 102918 3 910791 341415 2 526191 134073 2 659609 133225 3 690293 561...
output:
35478 18624 78085 84422 64480 8449 51230 4571 89366 63494 34463 41028 36180 21314 30197 81273 40400 69808 42147 3988 98521 2452 13595 43642 69108 39646 93137 95922 39452 1217 10651 80682 35534 34784 49882 14755 73947 23645 38923 95063 30177 52114 49164 98219 208 98408 5373 71603 93716 11385 60484 18...
result:
ok correct
Test #14:
score: 0
Accepted
time: 326ms
memory: 8480kb
input:
1 100000 778411 171737 3 31198 657119 3 155563 369903 1 511917 119207 6 679674 248855 4 992610 588775 5 872187 572198 6 91683 913714 4 254664 416428 3 175000 463992 3 815710 281793 4 603132 358830 2 165958 576913 2 420069 533307 7 656775 410667 2 278481 287076 5 160586 153734 2 164979 126586 2 27930...
output:
10495 78296 86975 66984 43573 26013 68012 28684 21728 84715 73054 55225 80985 71471 19208 75959 3227 49197 78757 51517 90370 45175 30815 33044 22612 38359 10155 50081 38746 20159 29238 80523 64318 24082 8081 80300 49009 47185 51927 50099 81484 31393 93483 48777 27137 18152 11576 10916 63727 96750 55...
result:
ok correct
Test #15:
score: 0
Accepted
time: 325ms
memory: 8540kb
input:
1 99999 451551 900548 5 783958 575297 1 756073 750709 5 605124 150049 5 907304 667919 2 190198 335808 4 508533 538310 7 525460 422171 6 409034 310537 1 268526 129603 1 484955 798337 5 946101 116345 4 215220 404493 1 495671 549960 7 340051 637372 6 169627 688226 2 206600 629835 3 191133 480511 4 3188...
output:
54269 84814 11203 22266 69715 2067 98594 58686 77120 97588 24647 22779 41418 74818 11208 77299 68401 83198 48458 83840 10016 73446 1390 25559 11910 57243 94269 68865 21808 3045 36095 77465 14015 56072 4637 32888 22833 39225 85587 87637 73770 70840 9918 92119 76820 76804 18268 93252 20843 97020 35269...
result:
ok correct
Test #16:
score: 0
Accepted
time: 319ms
memory: 8540kb
input:
1 100000 783156 687878 1 477270 782181 2 122423 521187 1 814765 379647 8 906893 42584 3 464361 836497 8 935935 677655 6 966066 829735 7 348885 726636 6 474870 178304 5 901105 792063 5 940836 193643 7 785900 806988 3 38183 973599 4 814963 945121 3 570021 666591 6 840996 939097 7 406903 216975 2 62090...
output:
72039 60446 79913 606 67084 74974 38540 46212 13925 18473 33329 54770 80078 8805 94531 69295 94929 82414 11017 59740 69274 52094 98394 64031 74594 3026 65376 40859 93220 16215 56539 99398 84080 23209 38748 2719 88190 13990 91697 28371 94299 21350 58000 46528 27 406 68868 13024 13756 32181 12213 6526...
result:
ok correct
Test #17:
score: 0
Accepted
time: 327ms
memory: 8340kb
input:
1 99999 45362 965532 6 708808 306508 2 624384 151389 1 467716 670928 1 39438 96594 5 942210 88149 7 892926 875304 8 241522 637190 1 564772 772170 8 835563 334036 7 104129 627390 5 911109 785971 7 389695 864643 9 475004 239058 3 432237 738985 3 818115 349146 8 665532 910961 8 964582 950889 9 682361 7...
output:
17464 54738 19792 69939 35189 77452 89261 55631 50252 91841 70330 4005 64528 98810 51735 25631 44169 2070 89979 41652 86742 62362 45691 29466 82233 78136 91194 51184 6693 82962 21064 93923 22440 83984 47051 39021 91148 97090 43528 17339 33500 58672 69501 561 7869 9766 74630 46576 40530 51413 7570 62...
result:
ok correct
Test #18:
score: 0
Accepted
time: 324ms
memory: 8488kb
input:
1 100000 545343 214678 2 896330 34297 10 225650 145117 5 3539 141992 10 866014 337066 4 787360 33077 10 990193 565400 7 746446 687990 6 657093 370479 9 221001 777823 3 818490 795673 2 891597 771810 3 322069 291555 3 680477 429062 4 131032 471991 3 498884 709254 9 4962 615960 7 537100 173421 1 166345...
output:
47267 41095 99945 82746 72235 4514 7505 33683 57213 5896 21646 65793 2233 37477 35903 26024 55083 75580 81907 2157 93532 35053 37297 29849 58079 67046 3739 68803 90621 34886 53352 54246 56947 73238 88362 25725 54684 92792 65858 7259 30656 70002 31250 66964 37747 13385 86380 82236 46760 47662 82866 1...
result:
ok correct
Test #19:
score: -100
Wrong Answer
time: 398ms
memory: 8396kb
input:
1 99999 336110 764075 4 762927 765956 4 275286 70789 5 459972 469529 7 870966 316414 7 498229 41636 11 830500 307315 6 854475 488251 5 759873 905341 5 993842 970385 9 217019 809676 12 207189 933113 4 625602 520131 7 736635 340574 11 921162 795091 6 552353 769663 10 406594 84507 8 465432 768495 3 892...
output:
39708 59543 43462 38768 62809 86685 85130 49266 10175 30405 5060 45395 16901 19161 77253 78326 74569 15283 81622 25091 32911 13276 24367 31315 53191 86779 19835 56034 94131 84931 2385 7006 43089 26503 35302 20787 17665 96835 31205 81685 18723 58976 78156 39068 12414 83152 77700 16443 27841 74989 144...
result:
wrong answer Wrong Answer on Case#1