QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#96866 | #5561. Improving IT | _b_ | WA | 1ms | 7740kb | C++14 | 904b | 2023-04-15 17:01:13 | 2023-04-15 17:01:17 |
Judging History
answer
#include<iostream>
#include<string.h>
using namespace std;
const int MAXN = 5e5 + 50;
#define ll long long
struct Edge {
int x, y, w;
}edge[MAXN];
int n, m, bian;
ll dist[MAXN];
ll 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 << 62) {
if (dist[x] + w < dist[y]) {
dist[y] = dist[x] + w;
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: 0
Wrong Answer
time: 1ms
memory: 7740kb
input:
4 3 1000 900 800 900 700 600 500 400 1200 1200 1300 600 500
output:
9187201950435737471
result:
wrong answer 1st lines differ - expected: '100', found: '9187201950435737471'