QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#608450 | #6120. Good Pizza | qtoq# | AC ✓ | 15ms | 3964kb | C++23 | 2.7kb | 2024-10-03 22:00:04 | 2024-10-03 22:00:04 |
Judging History
answer
//thatsramen
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define ft first
#define sd second
#define pi pair<int, int>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dbg(...) dbg_out(__VA_ARGS__)
using ll = long long;
using ld = long double;
using namespace std;
using namespace __gnu_pbds;
//Constants
const ll INF = 5 * 1e18;
const int IINF = 2 * 1e9;
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ld PI = 3.14159265359;
//Templates
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) {return os << '(' << p.first << ", " << p.second << ')';}
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) {os << '['; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << ']';}
void dbg_out() {cerr << endl;}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << H << ' '; dbg_out(T...); }
template<typename T> bool mins(T& x, T y) { if (x > y) { x = y; return true; } return false; }
template<typename T> bool maxs(T& x, T y) { if (x < y) { x = y; return true; } return false; }
template<typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using omset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
//order_of_key(k): number of elements strictly less than k
//find_by_order(k): k-th element in the set
void setPrec() {cout << fixed << setprecision(15);}
void unsyncIO() {cin.tie(0)->sync_with_stdio(0);}
void setIn(string s) {freopen(s.c_str(), "r", stdin);}
void setOut(string s) {freopen(s.c_str(), "w", stdout);}
void setIO(string s = "") {
unsyncIO(); setPrec();
if(s.size()) setIn(s + ".in"), setOut(s + ".out");
}
// #define TEST_CASES
void solve() {
int n;
cin >> n;
vector<pi> al(n);
for (auto &[x, y] : al) {
cin >> x >> y;
}
sort(all(al), [](pi x, pi y) -> bool {
int a = x.sd * (2 * y.ft + 1);
int b = y.sd * (2 * x.ft + 1);
return b < a;
});
// dbg(al);
ll ans = 0;
ll sum = 0;
for (int i = 0; i < n; i++) {
sum += al[i].ft;
ans += 1ll * (sum + i) * al[i].sd;
sum += al[i].ft;
}
cout << ans;
}
int main() {
setIO();
int tt = 1;
#ifdef TEST_CASES
cin >> tt;
#endif
while (tt--)
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3528kb
input:
3 10 3 3 8 4 2
output:
124
result:
ok 1 number(s): "124"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
10 17 62 30 79 99 2 88 57 42 46 84 11 44 60 21 98 68 63 17 54
output:
118250
result:
ok 1 number(s): "118250"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
43 92 83 99 20 100 60 89 10 60 85 1 19 60 4 75 23 53 22 31 84 2 29 72 52 72 18 48 39 1 37 17 79 13 31 89 74 92 76 9 26 77 35 98 1 76 89 72 26 93 49 42 79 7 54 67 68 27 48 5 94 57 4 98 77 13 32 11 37 9 7 81 77 8 26 24 14 51 92 80 64 34 29 90 43 18 63
output:
2242658
result:
ok 1 number(s): "2242658"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
32 20 43 20 64 5 18 7 70 10 44 13 94 51 20 95 23 66 37 44 23 27 39 45 16 94 65 14 62 80 63 10 64 98 90 23 15 20 30 92 58 95 100 7 56 97 31 15 43 87 31 6 26 6 78 88 76 69 65 20 1 3 37 82 11
output:
1014143
result:
ok 1 number(s): "1014143"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
80 77 87 11 34 78 7 8 18 83 54 91 25 79 55 60 80 96 2 18 66 80 81 5 74 30 86 45 7 19 50 77 22 57 22 61 68 52 60 26 64 54 32 20 12 72 61 47 50 85 94 71 100 54 46 74 4 65 26 2 45 33 42 54 67 73 61 41 51 1 97 78 88 59 31 52 6 22 62 27 54 58 97 18 11 26 58 3 21 56 87 28 90 23 2 40 18 69 43 52 40 100 97 ...
output:
8228220
result:
ok 1 number(s): "8228220"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
98 46 10 13 99 67 69 23 83 17 86 10 78 64 91 88 98 88 15 55 16 7 85 99 43 89 69 19 86 14 65 7 82 93 96 11 34 40 96 64 65 52 39 42 42 52 43 23 45 50 60 8 30 42 98 25 10 56 2 62 86 34 24 34 90 27 93 33 43 15 40 77 36 1 65 45 75 62 72 72 85 36 72 40 60 33 34 82 48 90 60 72 13 84 88 98 18 34 29 13 68 71...
output:
13754870
result:
ok 1 number(s): "13754870"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
43 54 31 93 27 18 19 40 34 89 82 71 54 30 27 75 87 75 31 54 34 21 78 77 86 63 1 74 70 90 40 7 15 20 40 25 8 84 58 28 46 57 70 1 100 52 64 77 84 54 85 33 14 61 63 2 62 70 4 45 64 60 5 36 50 98 73 50 75 33 37 46 13 21 83 9 61 59 18 33 22 95 23 74 46 83 51
output:
2623535
result:
ok 1 number(s): "2623535"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3756kb
input:
34 20 42 95 49 90 25 95 80 27 80 84 14 84 39 41 32 76 29 42 58 52 80 77 7 65 41 42 91 39 91 21 10 37 32 17 38 57 50 70 17 49 33 67 17 54 13 42 98 6 9 82 1 65 83 87 63 46 59 97 45 15 22 28 12 83 21 35 31
output:
1475049
result:
ok 1 number(s): "1475049"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
35 1 45 58 22 81 82 12 31 52 61 69 58 7 47 38 86 94 86 35 72 46 59 71 46 77 22 41 29 55 63 68 6 26 1 61 42 37 56 43 34 4 62 31 12 75 50 87 47 7 18 54 88 21 60 57 54 57 74 80 60 72 32 44 89 35 64 1 85 30 63
output:
1738455
result:
ok 1 number(s): "1738455"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
53 32 79 17 73 82 19 15 71 68 23 98 36 74 6 25 80 93 54 100 42 73 34 16 5 37 64 87 80 71 61 14 3 86 7 98 55 1 33 35 80 32 61 41 41 96 16 14 84 57 42 75 25 23 55 51 2 78 18 3 33 40 84 24 91 16 60 100 70 6 90 8 49 46 48 49 3 4 3 69 83 55 86 61 65 50 35 92 28 14 52 96 25 48 89 78 15 51 38 79 62 99 67 1...
output:
3143769
result:
ok 1 number(s): "3143769"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
40 93 88 65 29 62 98 62 41 60 50 18 54 58 4 33 58 32 49 46 77 29 41 33 71 18 81 65 28 87 20 29 97 90 17 3 40 63 83 15 61 88 31 57 80 14 6 66 85 52 78 64 3 71 59 97 47 10 18 59 55 58 68 98 99 8 94 73 48 32 36 57 80 83 66 55 86 39 90 55 42
output:
2828773
result:
ok 1 number(s): "2828773"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
42 60 2 82 30 54 9 27 17 2 75 36 36 91 3 2 85 11 19 62 8 94 45 71 16 5 93 12 23 1 78 67 14 86 15 88 3 80 21 14 12 60 7 45 25 62 61 6 15 22 86 80 32 86 15 57 59 79 27 25 24 52 78 62 23 93 15 19 57 9 85 7 80 60 46 98 72 86 84 40 35 33 2 41 16
output:
1134960
result:
ok 1 number(s): "1134960"
Test #13:
score: 0
Accepted
time: 2ms
memory: 3852kb
input:
9712 714 112 644 660 686 209 14 495 691 352 916 289 47 127 962 364 247 46 351 463 113 746 289 286 570 971 238 529 850 974 292 440 79 760 927 270 483 75 405 480 405 403 724 760 259 248 572 303 93 396 574 677 832 98 888 646 698 107 547 476 739 988 614 148 785 2 890 210 749 511 265 951 677 579 857 9 14...
output:
12113284901205
result:
ok 1 number(s): "12113284901205"
Test #14:
score: 0
Accepted
time: 11ms
memory: 3784kb
input:
73014 945 834 564 203 391 487 9 281 999 81 458 633 209 992 598 710 216 87 921 772 548 832 32 462 234 111 115 598 494 536 676 966 540 710 896 412 263 611 958 645 349 728 491 213 710 337 849 239 890 69 189 699 753 255 263 967 358 46 221 605 998 30 477 33 417 533 681 939 83 671 902 621 89 281 687 7 97 ...
output:
696460348582091
result:
ok 1 number(s): "696460348582091"
Test #15:
score: 0
Accepted
time: 8ms
memory: 3592kb
input:
51200 133 303 764 481 482 407 528 712 137 859 909 142 350 921 208 199 572 34 91 871 909 725 885 792 549 895 144 954 7 391 509 460 138 653 103 168 235 125 170 843 894 653 647 886 304 34 398 986 319 608 395 134 167 505 635 277 185 865 627 917 43 548 704 388 453 795 228 912 694 257 571 527 772 534 518 ...
output:
342483638839725
result:
ok 1 number(s): "342483638839725"
Test #16:
score: 0
Accepted
time: 11ms
memory: 3792kb
input:
70950 171 687 656 321 74 101 334 64 104 313 31 817 323 892 811 290 390 766 197 614 178 791 467 791 806 507 262 651 776 937 637 794 900 762 138 655 813 467 725 139 906 745 92 467 949 577 402 571 773 501 176 835 254 336 574 277 656 529 324 472 785 437 798 619 226 796 841 287 51 25 284 997 500 597 629 ...
output:
653708153914900
result:
ok 1 number(s): "653708153914900"
Test #17:
score: 0
Accepted
time: 9ms
memory: 3964kb
input:
79157 472 23 774 283 437 589 898 333 965 258 704 305 275 86 20 245 761 334 769 693 938 309 568 373 754 480 713 533 347 185 204 260 376 539 770 885 415 614 620 78 731 893 244 795 518 779 980 411 587 596 416 420 222 354 636 22 477 344 450 684 282 698 512 332 846 141 9 229 701 195 814 621 965 878 826 9...
output:
815097261870494
result:
ok 1 number(s): "815097261870494"
Test #18:
score: 0
Accepted
time: 6ms
memory: 3564kb
input:
56369 580 537 162 690 460 98 771 352 262 381 363 901 904 993 786 484 729 198 858 750 158 736 614 15 394 162 126 50 159 441 804 470 706 588 600 973 225 767 377 881 799 33 4 894 610 815 558 32 763 707 791 748 992 781 26 549 559 261 833 754 506 926 43 343 363 153 432 321 783 969 199 827 760 202 946 85 ...
output:
417287775820482
result:
ok 1 number(s): "417287775820482"
Test #19:
score: 0
Accepted
time: 2ms
memory: 3680kb
input:
8942 65 749 219 846 703 13 290 34 322 463 65 822 340 1 222 570 245 979 447 376 370 748 277 312 853 43 182 654 622 47 750 180 658 650 764 345 205 9 642 706 37 278 945 588 765 222 695 564 263 412 182 829 460 414 891 565 832 557 32 585 381 149 633 695 765 483 587 730 884 991 155 545 860 759 501 16 382 ...
output:
10304529284651
result:
ok 1 number(s): "10304529284651"
Test #20:
score: 0
Accepted
time: 9ms
memory: 3900kb
input:
80282 812 541 585 975 711 689 231 685 823 973 947 94 429 169 401 159 391 340 855 388 862 128 981 895 171 396 92 384 698 633 972 640 15 934 399 306 148 846 647 441 283 267 496 971 664 840 153 835 90 112 504 843 587 687 594 300 527 54 621 50 857 619 839 565 748 517 6 380 834 319 525 665 185 108 182 77...
output:
837422355199800
result:
ok 1 number(s): "837422355199800"
Test #21:
score: 0
Accepted
time: 14ms
memory: 3816kb
input:
90182 198 77 648 613 677 896 856 138 522 614 444 659 297 225 534 370 999 929 62 320 557 887 565 137 616 311 739 985 340 638 712 46 438 280 615 648 90 554 682 999 709 845 287 574 385 89 664 101 884 911 213 681 775 938 773 572 122 958 940 875 253 801 899 721 503 554 413 462 828 819 82 99 988 927 532 1...
output:
1060276461411598
result:
ok 1 number(s): "1060276461411598"
Test #22:
score: 0
Accepted
time: 3ms
memory: 3920kb
input:
16301 121 958 958 31 795 605 620 606 91 698 996 188 847 564 905 330 719 397 661 805 335 597 124 217 407 541 906 261 516 392 912 948 85 57 858 23 665 77 765 888 967 431 985 995 393 545 382 695 430 330 212 261 92 209 566 403 867 509 585 918 662 371 305 267 521 258 701 280 303 19 814 897 690 330 202 50...
output:
35301016299897
result:
ok 1 number(s): "35301016299897"
Test #23:
score: 0
Accepted
time: 11ms
memory: 3824kb
input:
99237 191 119 517 255 657 262 213 293 401 918 865 91 615 582 470 110 933 469 338 797 541 934 710 698 693 588 48 468 904 981 509 510 58 511 522 126 615 859 212 617 259 677 480 279 468 86 841 978 590 669 349 159 720 745 545 753 838 895 41 792 102 636 925 271 854 100 355 235 914 609 881 236 467 292 134...
output:
1267021237523392
result:
ok 1 number(s): "1267021237523392"
Test #24:
score: 0
Accepted
time: 15ms
memory: 3816kb
input:
99817 144 940 734 588 168 723 590 169 237 516 983 494 219 975 609 886 238 501 423 793 173 219 203 187 557 1 960 958 97 219 128 796 34 991 632 688 426 439 745 652 53 7 354 866 70 50 919 546 830 538 975 738 875 47 290 505 857 985 257 701 166 781 695 356 784 408 38 598 259 444 544 963 693 835 91 501 76...
output:
1292805087360614
result:
ok 1 number(s): "1292805087360614"
Test #25:
score: 0
Accepted
time: 15ms
memory: 3900kb
input:
99693 901 479 438 27 522 604 978 522 254 701 158 894 719 649 680 883 414 67 44 993 292 43 142 770 903 671 3 668 708 647 898 237 589 756 860 414 70 475 251 679 71 865 664 449 163 824 149 930 738 78 217 570 668 932 590 242 690 384 528 304 596 228 717 133 933 522 302 356 679 400 303 865 900 56 423 803 ...
output:
1287817264701736
result:
ok 1 number(s): "1287817264701736"
Test #26:
score: 0
Accepted
time: 15ms
memory: 3808kb
input:
99520 928 4 787 482 614 71 369 320 659 645 197 588 360 376 66 847 188 581 437 812 241 855 883 864 181 195 348 189 345 704 557 343 494 377 115 251 734 99 773 912 983 854 471 466 179 651 876 416 606 110 596 501 669 110 512 820 337 301 92 251 301 68 954 255 278 670 523 588 614 151 732 950 687 64 817 27...
output:
1292357680137903
result:
ok 1 number(s): "1292357680137903"
Test #27:
score: 0
Accepted
time: 15ms
memory: 3840kb
input:
99272 483 756 981 479 694 10 38 375 717 926 918 685 236 498 560 859 929 838 680 697 50 204 719 366 380 388 512 316 495 724 759 7 651 35 936 498 782 153 664 42 936 733 694 398 33 899 830 741 987 240 438 119 790 500 820 869 683 534 120 317 25 137 495 919 800 227 648 704 635 239 908 680 786 266 537 23 ...
output:
1284181505273625
result:
ok 1 number(s): "1284181505273625"
Test #28:
score: 0
Accepted
time: 15ms
memory: 3892kb
input:
99394 384 1000 675 798 827 939 45 8 109 111 964 970 430 699 648 666 161 522 469 13 369 961 836 389 598 445 227 624 980 542 727 561 560 265 90 258 549 397 549 629 758 120 742 950 982 877 140 747 552 325 20 78 762 181 307 974 850 475 864 877 174 193 851 266 24 988 828 571 103 954 666 949 50 317 508 23...
output:
1285719737041979
result:
ok 1 number(s): "1285719737041979"
Test #29:
score: 0
Accepted
time: 15ms
memory: 3944kb
input:
99553 503 294 200 140 651 390 141 289 513 361 344 783 875 388 830 410 170 453 292 349 586 727 533 111 925 692 56 584 588 345 392 924 815 441 385 440 984 134 949 418 9 461 58 909 998 535 21 135 595 848 743 450 526 915 241 159 92 935 433 406 694 40 669 583 35 856 385 997 706 849 644 339 919 623 803 17...
output:
1290941187702202
result:
ok 1 number(s): "1290941187702202"
Test #30:
score: 0
Accepted
time: 15ms
memory: 3816kb
input:
99604 428 612 525 704 609 545 700 195 612 969 918 546 446 968 515 966 57 287 809 900 92 646 780 669 552 972 879 258 930 401 771 504 625 152 32 45 77 927 541 257 409 138 859 862 847 582 205 593 47 17 394 28 660 680 288 747 418 642 523 193 191 683 632 62 335 810 235 114 114 407 79 221 962 242 239 33 5...
output:
1290537634947671
result:
ok 1 number(s): "1290537634947671"
Test #31:
score: 0
Accepted
time: 15ms
memory: 3820kb
input:
99879 62 646 598 393 335 536 538 354 496 182 523 455 432 990 454 71 908 930 106 47 422 297 318 614 596 994 8 23 924 799 442 132 49 396 81 683 15 740 885 683 949 296 74 985 250 15 541 116 240 184 297 325 754 440 197 516 677 628 437 669 518 639 354 514 961 970 7 715 369 35 239 574 741 799 140 129 812 ...
output:
1301065199919018
result:
ok 1 number(s): "1301065199919018"
Test #32:
score: 0
Accepted
time: 11ms
memory: 3776kb
input:
99727 63 638 107 455 422 90 479 356 635 563 253 519 879 69 48 244 145 658 850 996 593 534 793 217 934 112 490 341 277 252 183 574 929 91 263 576 209 227 19 199 769 733 370 671 121 179 463 760 794 69 351 772 425 572 113 416 906 231 503 821 986 340 35 580 862 255 10 684 502 996 956 79 750 806 333 284 ...
output:
1289707096835996
result:
ok 1 number(s): "1289707096835996"