QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#800811 | #3151. Railroad Trip | modwwe | 100 ✓ | 19ms | 5296kb | C++23 | 2.2kb | 2024-12-06 15:50:40 | 2024-12-06 15:50:44 |
Judging History
answer
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define mask(k) (1<<k)
#define mp make_pair
#define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms";
using namespace std;
#define getchar_unlocked getchar
inline int scan()
{
char c = getchar_unlocked();
int x = 0;
while (c < '0' || c > '9')
{
c = getchar_unlocked();
}
while (c >= '0' && c <= '9')
{
x = (x << 1) + (x << 3) + c - '0';
c = getchar_unlocked();
}
return x;
}
void phongbeo();
const int inf = 1e16;
const ll mod2 = 1e9+7;
const int mod1 = 998244353;
const ll base=67;
int add(int x,int y)
{
if(x+y>=mod2) x-=mod2;
if(x+y<0)x+=mod2;
return x+y;
}
struct icd
{
long double a;
int b;
};
struct ib
{
int a;
int b;
};
struct ic
{
ll a;
int b, c;
};
struct id
{
int a, b, c, d;
};
struct ie
{
int a, b, c, d, e;
};
int n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, mid, l2, r2, center;
int i, s10, s12,k1,k2,k3,s11,lim,w,l,r ;
int kk;
int el = 19;
main()
{
if(fopen(task".inp","r"))
{
fin(task);
fou(task);
}
NHP
/// cin>>s1;
// modwwe
phongbeo();
// checktime
}
int p[100001];
int pre[100001];
void phongbeo()
{
cin>>n>>m;
for(int i=1;i<=m;i++)
{
cin>>p[i];
}
for(int i=1;i<m;i++)
{
pre[min(p[i],p[i+1])]++;
pre[max(p[i],p[i+1])]--;
}
for(int i=1;i<=n;i++)
pre[i]+=pre[i-1];
s4=0;
for(int i=1;i<=n;i++)
{
cin>>l>>r>>s2;
s4+=min(l*pre[i],r*pre[i]+s2);
}
cout<<s4;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 20
Accepted
Test #1:
score: 20
Accepted
time: 1ms
memory: 3616kb
input:
50 2 20 24 112 97 73 314 238 48 864 605 33 704 537 215 974 488 162 867 748 59 870 250 355 688 503 394 363 259 896 722 268 938 839 363 422 96 80 557 246 213 186 320 43 647 343 93 452 593 542 148 634 440 578 498 279 576 63 48 214 318 304 41 77 31 496 966 686 365 342 190 767 998 994 325 958 698 638 114...
output:
1703
result:
ok single line: '1703'
Test #2:
score: 20
Accepted
time: 0ms
memory: 3624kb
input:
500 2 83 159 509 343 353 540 283 976 397 300 569 300 183 47 85 36 731 510 406 745 6 1 652 526 486 994 273 33 146 571 357 319 296 125 247 57 35 255 148 44 286 31 3 52 306 25 580 469 143 442 438 74 198 4 2 156 722 623 205 635 215 613 365 325 974 671 430 798 470 123 601 81 23 51 198 29 924 622 319 908 ...
output:
35659
result:
ok single line: '35659'
Test #3:
score: 20
Accepted
time: 1ms
memory: 3696kb
input:
1000 2 46 194 317 211 513 610 294 32 985 852 961 316 61 927 601 122 688 994 818 671 749 713 793 783 77 354 513 64 524 497 448 296 71 48 787 411 73 274 668 458 532 438 176 455 58 30 161 907 777 893 641 204 131 656 317 24 183 43 204 310 220 223 273 247 353 905 27 10 809 552 526 903 82 856 187 6 245 71...
output:
66224
result:
ok single line: '66224'
Test #4:
score: 20
Accepted
time: 0ms
memory: 3684kb
input:
100 2 9 29 714 580 793 836 633 960 518 3 497 911 307 759 711 70 589 117 42 69 608 303 90 421 346 202 578 437 800 660 227 688 707 398 246 576 408 84 352 171 446 961 317 954 738 723 1 502 434 536 782 689 693 522 434 318 641 194 818 998 611 221 852 831 729 854 808 14 985 712 366 650 643 947 801 629 699...
output:
14621
result:
ok single line: '14621'
Test #5:
score: 20
Accepted
time: 0ms
memory: 3744kb
input:
500 2 463 52 505 211 234 114 33 576 883 180 474 234 180 430 50 42 574 684 446 482 396 170 24 207 17 978 706 253 932 104 27 893 711 317 154 559 477 656 702 24 871 689 580 121 95 52 331 221 15 546 691 510 764 121 55 74 491 422 4 46 27 473 548 195 783 400 175 982 109 53 918 610 469 702 777 34 658 411 1...
output:
263511
result:
ok single line: '263511'
Test #6:
score: 20
Accepted
time: 0ms
memory: 3628kb
input:
1000 2 428 87 904 799 514 440 190 160 416 46 10 34 1 582 144 121 527 72 16 180 485 331 375 637 322 362 914 107 302 507 51 60 103 70 43 670 663 22 930 775 683 239 79 814 200 82 371 687 416 532 553 367 560 732 463 94 179 21 171 226 73 317 413 207 901 386 36 717 710 508 604 132 76 604 977 196 64 116 63...
output:
220916
result:
ok single line: '220916'
Test #7:
score: 20
Accepted
time: 1ms
memory: 3628kb
input:
1000 2 889 622 710 107 674 410 353 536 5 4 402 649 201 142 274 228 340 821 443 214 786 614 318 759 700 714 522 125 40 469 340 899 492 253 935 819 177 467 221 111 149 943 734 649 191 137 306 96 85 511 824 214 577 200 167 10 26 25 590 514 289 687 798 574 314 375 65 801 575 86 63 615 187 967 270 131 66...
output:
172283
result:
ok single line: '172283'
Test #8:
score: 20
Accepted
time: 1ms
memory: 3700kb
input:
1000 2 354 157 110 80 954 736 303 120 537 524 938 449 418 294 368 341 337 89 57 168 599 549 669 989 675 962 730 260 2 92 32 870 584 13 310 714 691 177 582 167 985 603 111 558 895 58 530 91 39 533 653 364 685 18 13 990 738 56 477 136 104 179 25 15 668 354 287 250 613 499 689 28 1 97 679 231 167 386 2...
output:
125368
result:
ok single line: '125368'
Subtask #2:
score: 30
Accepted
Test #9:
score: 30
Accepted
time: 1ms
memory: 3644kb
input:
1000 1000 839 952 525 963 454 835 241 779 102 772 734 910 419 513 77 47 977 891 560 334 396 843 943 114 386 4 82 956 289 935 631 974 47 480 495 887 884 759 552 656 321 748 417 942 258 140 217 975 888 191 589 498 943 617 5 178 970 202 613 737 994 387 585 914 241 935 329 79 855 913 212 218 791 879 608...
output:
84704653
result:
ok single line: '84704653'
Test #10:
score: 30
Accepted
time: 0ms
memory: 3708kb
input:
1000 1000 304 487 990 715 734 332 778 811 878 844 270 557 188 649 510 21 652 377 262 536 66 802 224 703 849 386 436 564 102 912 340 658 368 562 581 797 115 410 173 119 652 716 79 254 595 365 260 791 654 486 527 436 950 475 252 17 378 321 497 261 14 334 601 483 20 787 261 970 306 662 815 977 273 209 ...
output:
81939862
result:
ok single line: '81939862'
Test #11:
score: 30
Accepted
time: 0ms
memory: 3696kb
input:
1000 1000 765 22 599 307 894 881 171 739 654 780 662 752 881 225 511 27 255 623 500 698 928 501 205 767 795 370 180 349 720 16 181 297 793 546 633 163 295 503 764 749 910 863 58 681 353 331 849 632 114 857 584 130 51 708 239 165 454 619 968 792 415 880 367 737 39 63 570 206 600 616 908 152 140 766 9...
output:
168183763
result:
ok single line: '168183763'
Test #12:
score: 30
Accepted
time: 1ms
memory: 3700kb
input:
1000 1000 230 557 64 59 174 378 708 771 430 852 198 399 650 361 944 665 262 389 202 28 470 568 486 719 748 946 612 583 802 873 938 56 811 223 380 553 963 69 618 78 338 774 125 46 248 328 785 722 483 123 928 967 951 952 86 273 838 620 431 216 420 100 893 555 469 885 524 165 881 813 854 61 467 380 821...
output:
159938950
result:
ok single line: '159938950'
Test #13:
score: 30
Accepted
time: 1ms
memory: 3636kb
input:
1000 1000 691 804 665 715 574 743 389 755 814 756 590 665 232 306 962 896 606 772 847 877 500 712 323 407 703 658 204 930 522 79 90 442 885 75 595 661 352 811 462 947 375 811 650 62 770 737 242 887 248 707 566 413 216 923 726 811 76 605 550 819 256 127 503 557 567 928 204 142 535 785 144 114 533 923...
output:
167288803
result:
ok single line: '167288803'
Test #14:
score: 30
Accepted
time: 1ms
memory: 3628kb
input:
1000 1000 999 5 997 4 1000 1 999 5 998 1 1000 4 997 3 997 1 1000 5 997 3 996 1 1000 1 996 1 996 5 998 2 999 2 996 1 998 3 997 5 997 5 1000 5 1000 4 998 5 999 1 996 1 999 4 1000 5 999 1 1000 1 999 3 998 1 996 2 996 1 999 2 997 4 996 5 997 2 1000 5 996 2 996 3 1000 4 997 4 997 4 996 5 999 4 1000 2 996...
output:
256629092
result:
ok single line: '256629092'
Test #15:
score: 30
Accepted
time: 1ms
memory: 3704kb
input:
1000 1000 4 999 4 999 4 999 5 996 4 998 2 999 3 996 4 998 1 997 4 997 4 1000 1 1000 5 999 5 996 1 1000 4 999 3 998 3 1000 5 999 1 996 4 998 3 997 1 998 3 998 5 998 4 1000 3 999 2 997 4 997 5 997 2 1000 2 999 3 996 4 1000 2 999 2 998 3 997 3 997 5 997 3 996 5 997 1 1000 4 999 3 998 4 999 1 997 2 999 ...
output:
245581963
result:
ok single line: '245581963'
Test #16:
score: 30
Accepted
time: 1ms
memory: 3696kb
input:
1000 1000 999 4 996 4 996 1 999 2 996 4 997 1 999 2 999 5 999 5 999 2 998 3 996 5 999 1 999 4 997 3 998 5 998 1 998 2 999 3 998 4 997 3 999 1 996 1 997 5 996 3 997 1 997 5 996 2 997 5 997 2 998 4 999 2 999 2 996 5 996 3 997 1 999 5 996 5 1000 1 999 3 997 3 997 2 1000 1 996 5 998 2 998 2 996 3 996 5 ...
output:
495109366
result:
ok single line: '495109366'
Test #17:
score: 30
Accepted
time: 1ms
memory: 3700kb
input:
1000 1000 997 5 996 3 997 5 997 4 999 4 998 2 999 1 996 2 998 5 1000 3 996 4 997 2 1000 3 1000 1 999 1 998 1 999 5 997 1 999 5 997 5 1000 2 999 4 1000 4 999 4 997 4 998 3 1000 5 1000 4 998 1 999 4 997 2 998 3 997 2 998 5 999 3 997 3 1000 1 1000 2 996 3 996 2 998 2 997 5 996 3 996 1 996 5 996 5 999 5...
output:
508700490
result:
ok single line: '508700490'
Test #18:
score: 30
Accepted
time: 1ms
memory: 3704kb
input:
1000 1000 2 998 2 998 3 1000 3 1000 5 1000 3 1000 5 996 5 999 1 1000 1 997 4 999 2 998 5 999 2 998 4 998 2 996 1 1000 3 998 1 996 5 1000 4 999 4 1000 5 998 1 997 1 998 1 998 3 999 4 998 1 1000 1 997 4 996 2 1000 3 999 2 999 3 998 2 998 4 999 3 998 2 998 1 999 5 998 2 997 3 1000 3 997 4 999 4 999 4 9...
output:
512453496
result:
ok single line: '512453496'
Subtask #3:
score: 50
Accepted
Test #19:
score: 50
Accepted
time: 11ms
memory: 4404kb
input:
100000 1000 46639 8692 66173 66836 62025 62807 5881 48077 19739 99444 65378 80271 86992 92215 13660 89944 47507 58269 79357 44123 79854 74147 67585 59191 51795 72338 58922 79197 80521 19776 87576 61720 64577 69425 2620 59707 99144 41432 25403 14846 19624 24636 48563 49960 17673 97455 49782 55994 734...
output:
8422093195
result:
ok single line: '8422093195'
Test #20:
score: 50
Accepted
time: 19ms
memory: 5288kb
input:
100000 100000 81104 74227 638 6556 96233 2784 71418 28045 83867 90844 30914 28712 60647 54847 89875 37174 63642 94679 4287 53841 3968 99186 43882 4039 43108 29530 70538 22999 85135 13065 19179 74689 50035 49936 48041 10201 73828 35598 63569 1165 85492 80681 29992 19915 19672 51508 18806 65584 56143 ...
output:
83432334986269
result:
ok single line: '83432334986269'
Test #21:
score: 50
Accepted
time: 19ms
memory: 5168kb
input:
100000 100000 15565 39762 97247 79204 31465 82853 74811 15757 91739 8452 34306 60605 39678 25895 28490 59668 76005 36169 87481 89423 82058 37701 15027 8567 29490 12162 50218 86570 59405 29945 48358 91034 76326 35088 95773 98615 7792 23915 97520 51583 13126 5470 32401 36896 74102 81934 59095 65071 15...
output:
83297879180115
result:
ok single line: '83297879180115'
Test #22:
score: 50
Accepted
time: 5ms
memory: 4408kb
input:
100000 1000 50030 5297 31712 18924 65673 22830 40348 95725 55867 99852 99842 9046 13333 88527 4705 36562 38192 93475 12411 75013 2300 67640 91324 61607 36993 52394 61834 16932 25387 73712 24825 43471 36408 63281 71856 15253 12748 51377 84358 93552 10610 95183 6214 7251 14603 72849 10935 28377 10674 ...
output:
16801859415
result:
ok single line: '16801859415'
Test #23:
score: 50
Accepted
time: 11ms
memory: 5232kb
input:
100000 100000 81650 95120 28292 60692 28052 86835 19432 67885 45123 80436 51835 25326 45973 22450 18116 51177 77069 99204 53702 42310 66965 15241 58976 59632 2561 5185 47105 45733 33906 95009 46609 15567 49059 76743 37629 53800 58620 99434 80142 12541 71832 32041 15737 17631 42575 7194 64275 81213 5...
output:
166339392231656
result:
ok single line: '166339392231656'
Test #24:
score: 50
Accepted
time: 19ms
memory: 5168kb
input:
100000 100000 16113 60655 62755 4508 62260 30908 84967 83661 9251 75932 17371 3333 19646 72954 94347 78955 64232 24810 36968 75824 40231 84444 66327 5856 67954 82185 92801 65391 89080 6872 40078 45050 53777 98906 77008 98790 24960 86452 43048 32878 60036 62652 99790 57044 25074 65125 45651 65291 876...
output:
166474114551714
result:
ok single line: '166474114551714'
Test #25:
score: 50
Accepted
time: 15ms
memory: 4544kb
input:
100000 20000 100000 2 99997 2 99999 3 99999 3 99996 3 99998 1 99998 4 99999 3 99997 5 100000 2 99998 3 99996 4 100000 4 99998 4 99997 4 99997 2 99999 3 99999 1 99999 5 99998 5 99998 1 99997 2 99999 3 100000 3 100000 1 99997 5 99997 5 99999 2 99998 2 99998 1 99996 2 99998 2 99997 4 99997 1 99998 5 10...
output:
49901177921681
result:
ok single line: '49901177921681'
Test #26:
score: 50
Accepted
time: 18ms
memory: 5292kb
input:
100000 100000 5 100000 3 100000 2 99998 5 99996 2 99999 5 99999 2 100000 4 99998 4 99996 5 99996 3 99999 2 99999 5 100000 1 100000 5 99999 3 99997 5 99996 2 99996 2 99998 4 99999 4 100000 4 99997 2 100000 1 100000 3 99998 5 99998 1 100000 4 99996 4 99997 1 100000 2 99996 2 100000 3 99996 2 99999 1 9...
output:
249301707758244
result:
ok single line: '249301707758244'
Test #27:
score: 50
Accepted
time: 18ms
memory: 5240kb
input:
100000 100000 99997 5 99996 2 99999 2 99998 1 100000 1 100000 3 99997 3 100000 5 99999 4 99999 1 99999 3 100000 3 100000 5 99996 4 99999 4 99997 3 99998 5 99998 5 99999 5 100000 1 99999 4 99996 4 100000 3 99996 5 99998 3 99996 1 99997 5 99998 3 99996 1 99996 3 99998 4 99998 2 99998 1 100000 3 99999 ...
output:
249589264414801
result:
ok single line: '249589264414801'
Test #28:
score: 50
Accepted
time: 11ms
memory: 4572kb
input:
100000 20000 2 99998 2 100000 2 99997 1 99999 1 99997 5 99999 1 99996 5 99999 2 99999 2 100000 3 99997 1 99998 2 99996 1 99997 5 99999 5 99996 5 99997 1 99997 5 99998 5 100000 5 99999 2 99999 3 99999 1 100000 5 99997 1 99997 5 99998 4 99997 3 99997 4 99996 5 99999 5 99998 4 99996 4 100000 5 99999 1 ...
output:
99988866298982
result:
ok single line: '99988866298982'
Test #29:
score: 50
Accepted
time: 19ms
memory: 5292kb
input:
100000 100000 99997 5 99996 2 99998 3 99997 1 100000 4 99997 1 100000 1 100000 4 99997 2 100000 3 99996 5 99999 5 99998 3 99996 1 100000 3 99997 5 100000 5 99996 1 99996 4 99996 4 100000 4 99996 1 99997 2 100000 1 99996 3 99997 3 100000 1 99996 2 99998 4 100000 4 99998 3 99996 4 99999 4 100000 3 999...
output:
501432715278027
result:
ok single line: '501432715278027'
Test #30:
score: 50
Accepted
time: 19ms
memory: 5296kb
input:
100000 100000 2 99998 2 100000 1 99998 5 99999 1 100000 2 99997 4 99999 2 100000 1 99997 1 100000 5 99999 2 99998 5 99999 2 100000 2 99998 3 100000 3 100000 2 100000 1 100000 3 99998 4 99999 2 99998 4 99998 2 100000 3 100000 1 100000 2 99999 4 99998 3 99999 4 99999 4 99999 3 100000 1 99997 4 99998 1...
output:
500162872638199
result:
ok single line: '500162872638199'
Test #31:
score: 50
Accepted
time: 19ms
memory: 5164kb
input:
100000 100000 57369 19400 52587 26708 52347 69203 95151 80301 90187 18516 76116 94832 60479 20052 63273 8067 54110 78346 9686 7856 32221 32595 52695 13928 72949 9705 52897 79437 98848 47241 17424 94093 4876 45617 10950 77102 3311 60292 11482 69871 79314 39688 44119 29334 31665 42572 77202 34126 4570...
output:
83530947103474
result:
ok single line: '83530947103474'
Test #32:
score: 50
Accepted
time: 15ms
memory: 5288kb
input:
100000 100000 91834 84935 87052 66428 86555 9180 60688 59757 54315 9916 41652 39175 34136 82684 39490 7873 22903 28164 51032 8710 52207 63778 60064 52248 38950 37217 64513 48071 77914 6592 23475 20796 11034 66192 36951 74352 44107 6138 54132 73344 67334 12149 20228 85657 14128 83703 53682 34108 4677...
output:
83760315949752
result:
ok single line: '83760315949752'
Extra Test:
score: 0
Extra Test Passed