QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#374660 | #3502. Sightseeing in Kyoto | ltunjic# | 0 | 524ms | 31044kb | C++14 | 1.1kb | 2024-04-02 16:30:32 | 2024-07-04 03:33:19 |
Judging History
answer
#include <cstdio>
#include <set>
#define X first
#define Y second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const ll OO = 1e18;
const int N = 1010;
int n, m, A[N], B[N];
ll D[N][N];
set<pair<ll, pii>> S;
int main() {
scanf("%d%d", &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)
for(int j = 1; j <= m; ++j) {
if(i == 1 && j == 1) D[i][j] = 0;
else D[i][j] = OO;
S.insert({D[i][j], {i, j}});
}
while(!S.empty()) {
int x = (*S.begin()).Y.X;
int y = (*S.begin()).Y.Y;
S.erase(S.begin());
if(x != n && D[x + 1][y] > (ll) D[x][y] + B[y]) {
S.erase({D[x + 1][y], {x + 1, y}});
D[x + 1][y] = (ll) D[x][y] + B[y];
S.insert({D[x + 1][y], {x + 1, y}});
}
if(y != m && D[x][y + 1] > (ll) D[x][y] + A[x]) {
S.erase({D[x][y + 1], {x, y + 1}});
D[x][y + 1] = (ll) D[x][y] + A[x];
S.insert({D[x][y + 1], {x, y + 1}});
}
}
printf("%lld\n", D[n][m]);
return 0;
}
詳細信息
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 10
Accepted
time: 27ms
memory: 7772kb
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:
144700753486
result:
ok single line: '144700753486'
Test #2:
score: 0
Accepted
time: 2ms
memory: 8620kb
input:
489 2 972249103 697236949 967250764 681884473 636477380 692387561 796114900 896503411 763037576 531113684 822189792 807721830 379742704 846345706 410827375 402701704 288551124 936639599 375887198 452684376 312984818 244195135 486887067 586097199 539831363 306788937 900402922 677824462 416376869 3759...
output:
328323599204
result:
ok single line: '328323599204'
Test #3:
score: 0
Accepted
time: 2ms
memory: 6488kb
input:
323 8 945461002 972239828 497762984 785301370 848811267 781893207 883500216 606146710 897537367 693757813 773725023 641896522 644191887 883063599 971678650 612626656 627975243 513682284 958238083 481331187 448598476 690397378 810919101 466228458 520809215 642288505 459053386 425488261 729532078 5456...
output:
131909604852
result:
ok single line: '131909604852'
Test #4:
score: 0
Accepted
time: 0ms
memory: 6808kb
input:
211 6 300121025 10610632 642793775 820473527 52357847 790030800 930189727 478683824 604076353 442883453 868963075 458740167 956375465 402424884 523031876 526153589 125251913 93824897 767836934 456717799 932696378 585279523 565442853 533089757 384029723 733772180 715451948 677398582 104677992 1442538...
output:
24939943080
result:
ok single line: '24939943080'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3828kb
input:
7 8 324438357 888585680 228658980 633680643 553949653 919446743 26789616 733732803 467151303 946129278 774855331 974783731 656427372 391841553 441397515
output:
3288083871
result:
ok single line: '3288083871'
Test #6:
score: -10
Time Limit Exceeded
input:
1000 1000 974951229 572812767 61715338 58251108 992970132 292320832 346580154 883002624 576964058 294430934 705885668 17573757 290787136 184748452 110588470 132698209 364284483 39793402 636955202 414014896 895716291 779502490 194065320 111799307 938923636 424807575 673188421 208882345 776527514 4149...
output:
8615286430
result:
Subtask #2:
score: 0
Wrong Answer
Test #15:
score: 0
Wrong Answer
time: 524ms
memory: 31044kb
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:
103344
result:
wrong answer 1st lines differ - expected: '277650', found: '103344'
Subtask #3:
score: 0
Skipped
Dependency #1:
0%