QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#99141 | #3502. Sightseeing in Kyoto | eyiigjkn | 30 | 19ms | 6200kb | C++14 | 1.2kb | 2023-04-21 12:32:20 | 2023-04-21 12:32:21 |
Judging History
answer
# include <bits/stdc++.h>
using namespace std;
using ll=long long;
int a[100010],b[100010];
struct Frac
{
ll a;int b;
Frac(){}
Frac(ll a,int b):a(a),b(b){}
Frac &operator+=(const Frac &t){a+=t.a;b+=t.b;return *this;}
bool operator<(const Frac &t)const{return (ll)a*t.b<(ll)b*t.a;}
}stk1[100010];
struct Point
{
int x,y;
Point(){}
Point(int x,int y):x(x),y(y){}
Point operator-(const Point &t)const{return Point(x-t.x,y-t.y);}
ll operator*(const Point &t)const{return (ll)x*t.y-(ll)y*t.x;}
ll operator()(const Frac &t)const{return t.b*y-t.a*x;}
}stk2[100010];
int main()
{
int n,m,tp1=0,tp2=0;
cin>>n>>m;
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
for(int i=1;i<=m;i++) scanf("%d",&b[i]);
for(int i=1;i<n;i++) a[i]=a[i+1]-a[i];
for(int i=1;i<n;i++)
{
Frac cur(a[i],1);
for(;tp1 && cur<stk1[tp1];tp1--) cur+=stk1[tp1];
stk1[++tp1]=cur;
}
for(int i=1;i<=m;i++)
{
Point cur(i-1,b[i]);
while(tp2>1 && (cur-stk2[tp2])*(stk2[tp2]-stk2[tp2-1])>=0) tp2--;
stk2[++tp2]=cur;
}
ll ans=(ll)a[n]*(m-1);
for(int i=1,j=1;i<=tp1;i++)
{
while(j<tp2 && stk2[j+1](stk1[i])<stk2[j](stk1[i])) j++;
ans+=stk2[j](stk1[i]);
}
cout<<ans<<endl;
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3528kb
input:
55 985 972919143 571703632 545299240 122906268 313605426 768197556 821161013 810382136 607096032 550926769 636584830 233641411 664075312 999513344 919939491 226167158 374405025 792842315 461126245 212582686 538315759 397667313 770583715 411616307 363120565 690544971 780156662 507283838 215368652 461...
output:
216707272140
result:
wrong answer 1st lines differ - expected: '144700753486', found: '216707272140'
Subtask #2:
score: 30
Accepted
Test #15:
score: 30
Accepted
time: 2ms
memory: 5560kb
input:
307 1278 1000 991 983 975 967 959 952 944 936 928 920 913 905 897 889 882 874 867 859 852 844 837 829 822 815 808 800 793 786 779 772 764 757 750 743 736 730 723 716 709 702 695 689 682 675 669 662 655 649 642 636 630 623 617 610 604 598 592 585 579 573 567 561 555 549 543 537 531 525 519 514 508 50...
output:
277650
result:
ok single line: '277650'
Test #16:
score: 0
Accepted
time: 9ms
memory: 5416kb
input:
73984 7749 653 662 643 869 947 962 944 645 982 945 606 499 878 969 990 910 627 658 904 831 993 897 715 739 940 578 729 585 854 711 634 931 682 846 763 546 587 883 997 512 753 795 533 768 891 987 704 781 884 659 502 925 644 596 575 967 907 714 788 576 598 568 784 959 612 726 530 910 754 746 999 609 8...
output:
3853334
result:
ok single line: '3853334'
Test #17:
score: 0
Accepted
time: 3ms
memory: 5980kb
input:
126 75930 1000 921 846 774 705 640 578 518 462 410 360 314 271 231 194 160 130 103 79 58 40 26 15 7 2 1 1 1 1 2 3 4 5 7 9 10 13 15 17 20 23 26 29 33 37 40 45 49 53 58 63 68 73 79 85 90 97 103 109 116 123 130 137 145 152 160 168 177 185 194 203 212 221 231 240 250 260 271 281 292 303 314 325 337 348 ...
output:
197932
result:
ok single line: '197932'
Test #18:
score: 0
Accepted
time: 4ms
memory: 3612kb
input:
32784 12 871 147 880 18 991 126 865 615 605 633 457 52 756 435 318 857 362 460 130 861 720 339 201 562 834 853 378 652 742 669 371 909 341 318 92 127 535 112 722 388 654 862 443 687 859 600 118 566 700 531 715 194 442 539 905 353 613 558 132 811 342 710 746 138 585 932 399 11 489 861 656 137 911 933...
output:
2853516
result:
ok single line: '2853516'
Test #19:
score: 0
Accepted
time: 15ms
memory: 4280kb
input:
100000 100000 481 653 841 215 75 920 189 252 250 624 733 697 579 561 954 129 300 503 333 267 312 934 986 689 687 874 642 795 211 417 181 892 684 871 727 896 164 77 128 927 313 109 622 611 336 921 871 538 258 311 687 892 408 464 834 711 513 624 97 156 921 881 56 212 421 13 856 272 1 333 818 849 396 8...
output:
206470
result:
ok single line: '206470'
Test #20:
score: 0
Accepted
time: 19ms
memory: 4164kb
input:
100000 100000 279 297 599 861 394 613 447 183 733 686 42 294 245 975 381 201 850 772 501 629 500 314 575 10 397 401 926 194 220 484 820 366 16 66 451 574 546 993 993 918 137 716 144 892 305 248 234 704 775 689 46 925 754 889 427 956 706 318 825 41 984 706 984 248 421 421 699 730 951 231 480 544 400 ...
output:
207384
result:
ok single line: '207384'
Test #21:
score: 0
Accepted
time: 15ms
memory: 5840kb
input:
100000 100000 581 693 562 758 839 944 715 628 623 595 816 814 623 770 673 674 542 945 946 826 870 724 856 805 837 512 630 602 788 550 551 636 784 609 759 698 640 716 740 960 543 824 965 653 989 940 922 597 707 815 554 759 891 944 519 618 586 551 765 928 998 996 507 831 697 761 919 952 845 888 682 80...
output:
16781816
result:
ok single line: '16781816'
Test #22:
score: 0
Accepted
time: 11ms
memory: 4340kb
input:
100000 100000 629 659 881 805 903 835 862 528 835 970 659 879 921 721 961 984 680 675 781 996 646 961 970 517 809 845 726 960 575 604 867 551 719 671 963 780 964 892 836 782 996 882 932 848 646 905 569 509 541 612 754 626 634 787 725 570 686 787 932 936 914 624 791 600 625 522 913 832 868 990 843 92...
output:
18171753
result:
ok single line: '18171753'
Test #23:
score: 0
Accepted
time: 11ms
memory: 5708kb
input:
100000 100000 1000 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 998 9...
output:
66553767
result:
ok single line: '66553767'
Test #24:
score: 0
Accepted
time: 14ms
memory: 4408kb
input:
100000 100000 897 563 642 686 499 918 584 796 815 720 610 891 892 582 835 542 539 567 904 561 767 736 621 765 529 693 722 709 660 710 622 665 620 903 992 649 945 725 609 941 569 902 554 766 779 666 568 866 508 531 904 944 902 894 970 923 930 822 994 893 592 716 552 619 596 785 784 741 887 522 683 73...
output:
29059334
result:
ok single line: '29059334'
Test #25:
score: 0
Accepted
time: 18ms
memory: 6116kb
input:
100000 100000 776 547 926 751 631 750 624 907 679 560 700 721 820 988 580 733 572 742 954 535 733 951 894 991 647 683 604 746 947 607 736 799 514 855 840 846 769 602 743 896 843 573 548 913 896 842 690 991 776 694 771 938 599 852 868 538 841 927 703 634 635 765 837 757 656 676 654 959 959 979 774 61...
output:
32580184
result:
ok single line: '32580184'
Test #26:
score: 0
Accepted
time: 11ms
memory: 6200kb
input:
100000 100000 1000 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 934 933 932 931 930 929 928 927 9...
output:
99226519
result:
ok single line: '99226519'
Test #27:
score: 0
Accepted
time: 18ms
memory: 5732kb
input:
100000 100000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1...
output:
199998000
result:
ok single line: '199998000'
Test #28:
score: 0
Accepted
time: 2ms
memory: 3524kb
input:
2 2 943 460 257 623
output:
717
result:
ok single line: '717'
Test #29:
score: 0
Accepted
time: 2ms
memory: 3464kb
input:
2 3 213 562 705 42 69
output:
495
result:
ok single line: '495'
Test #30:
score: 0
Accepted
time: 2ms
memory: 5500kb
input:
3 2 4 787 132 217 830
output:
566
result:
ok single line: '566'
Test #31:
score: 0
Accepted
time: 0ms
memory: 3504kb
input:
5 2 621 818 614 372 775 996 527
output:
2729
result:
ok single line: '2729'
Test #32:
score: 0
Accepted
time: 2ms
memory: 5412kb
input:
2 9 440 438 963 286 600 965 71 632 115 810 923
output:
3583
result:
ok single line: '3583'
Test #33:
score: 0
Accepted
time: 2ms
memory: 5360kb
input:
6 5 458 127 174 414 874 919 828 702 139 835 549
output:
3189
result:
ok single line: '3189'
Test #34:
score: 0
Accepted
time: 2ms
memory: 5540kb
input:
9 5 943 334 271 14 893 872 964 30 965 270 102 56 432 466
output:
1572
result:
ok single line: '1572'
Test #35:
score: 0
Accepted
time: 2ms
memory: 5484kb
input:
6 8 770 278 753 735 514 696 333 511 256 214 609 359 833 659
output:
4487
result:
ok single line: '4487'
Test #36:
score: 0
Accepted
time: 1ms
memory: 5672kb
input:
8 6 369 308 180 278 813 292 109 376 48 869 945 644 1000 21
output:
854
result:
ok single line: '854'
Test #37:
score: 0
Accepted
time: 2ms
memory: 5676kb
input:
6 6 4 1 1 1 1 4 1 2 3 4 5 6
output:
15
result:
ok single line: '15'
Test #38:
score: 0
Accepted
time: 0ms
memory: 3388kb
input:
6 6 4 1 1 1 1 4 6 5 4 3 2 1
output:
15
result:
ok single line: '15'
Subtask #3:
score: 0
Skipped
Dependency #1:
0%