QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#96835 | #5561. Improving IT | _b_ | WA | 3ms | 7536kb | C++14 | 908b | 2023-04-15 16:50:56 | 2023-04-15 16:51:12 |
Judging History
answer
#include<iostream>
#include<string.h>
using namespace std;
const int MAXN = 5e5 + 50;
struct Edge {
int x, y, w;
}edge[MAXN];
int n, m, bian, dist[MAXN], pre[MAXN];
int solve(int s, int t) {
memset(dist, 127, sizeof(dist));
dist[s] = 0;
for (;;) {
bool ok = false;
for (int i = 1; i <= bian; i++) {
int x = edge[i].x; int y = edge[i].y; int w = edge[i].w;
if (dist[x] < 1 << 30) {
if (dist[x] + w < dist[y]) {
dist[y] = dist[x] + w;
pre[y] = x;
ok = true;
}
}
}
if (!ok)
break;
}
return dist[t];
}
int main() {
cin >> n >> m;
int cnt = 0;
for (int i = 1; i <= n; i++) {
int cost; cin >> cost; int sale;
for (int j = 0; j < min(m, n - i + 1); j++) {
cin >> sale;
edge[++cnt].x = i; edge[cnt].y = i + j + 1;
edge[cnt].w = cost - sale;
}
}
bian = cnt;
cout << solve(1, n + 1) << endl;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 7488kb
input:
4 3 1000 900 800 900 700 600 500 400 1200 1200 1300 600 500
output:
100
result:
ok single line: '100'
Test #2:
score: 0
Accepted
time: 3ms
memory: 7364kb
input:
3 2 200 300 400 400 300 200 300 500
output:
-400
result:
ok single line: '-400'
Test #3:
score: 0
Accepted
time: 3ms
memory: 7436kb
input:
1 1 145669255 454927004
output:
-309257749
result:
ok single line: '-309257749'
Test #4:
score: 0
Accepted
time: 1ms
memory: 7428kb
input:
1 1 639426798 25010755
output:
614416043
result:
ok single line: '614416043'
Test #5:
score: 0
Accepted
time: 0ms
memory: 7364kb
input:
4 3 844421851 757954402 420571580 258916750 511274721 404934137 783798589 303312726 476596954 583382039 908112885 504686855 281837844
output:
-238707898
result:
ok single line: '-238707898'
Test #6:
score: 0
Accepted
time: 3ms
memory: 7420kb
input:
4 1 844421851 757954402 420571580 258916750 511274721 404934137 783798589 303312726
output:
834948726
result:
ok single line: '834948726'
Test #7:
score: 0
Accepted
time: 3ms
memory: 7536kb
input:
1 4 844421851 757954402
output:
86467449
result:
ok single line: '86467449'
Test #8:
score: 0
Accepted
time: 3ms
memory: 7432kb
input:
4 4 844421851 757954402 420571580 258916750 511274721 404934137 783798589 303312726 476596954 583382039 908112885 504686855 281837844 755804204
output:
-1091094209
result:
ok single line: '-1091094209'
Test #9:
score: 0
Accepted
time: 1ms
memory: 5484kb
input:
10 5 844421851 757954402 420571580 258916750 511274721 404934137 783798589 303312726 476596954 583382039 908112885 504686855 281837844 755804204 618368996 250506341 909746255 982785476 810217235 902165950 310147569 729831748 898838287 683983931 472142715 100701208 434171835 610886973 913011053 96660...
output:
-1365452778
result:
ok single line: '-1365452778'
Test #10:
score: 0
Accepted
time: 3ms
memory: 7424kb
input:
10 5 639426798 25010755 275029318 223210738 736471214 676699487 892179567 86938832 421921819 29797219 218637974 505355288 26535969 198837650 649884437 544941480 220440622 589265683 809430456 6498759 805819251 698139394 340250516 155479499 957213072 336594545 92745843 96716376 847494366 603726031 807...
output:
-425588843
result:
ok single line: '-425588843'
Test #11:
score: -100
Wrong Answer
time: 2ms
memory: 7432kb
input:
100 50 844421851 757954402 420571580 258916750 511274721 404934137 783798589 303312726 476596954 583382039 908112885 504686855 281837844 755804204 618368996 250506341 909746255 982785476 810217235 902165950 310147569 729831748 898838287 683983931 472142715 100701208 434171835 610886973 913011053 966...
output:
-2147013374
result:
wrong answer 1st lines differ - expected: '-18994119385', found: '-2147013374'