QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#96863 | #5561. Improving IT | _b_ | WA | 1ms | 8264kb | C++14 | 904b | 2023-04-15 17:00:17 | 2023-04-15 17:00:27 |
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 << 60) {
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 8264kb
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'