# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
219370 | 2020-04-05T07:56:24 Z | ho94949 | 치료 계획 (JOI20_treatment) | C++17 | 318 ms | 196472 KB |
#include <bits/stdc++.h> using namespace std; const int MAXM = 5000; const long long INF = 0x3f3f3f3f3f3f3f3fLL; int N, M; int T[MAXM+2], L[MAXM+2], R[MAXM+2], C[MAXM+2]; long long cost[MAXM+2][MAXM+2]; long long dist[MAXM+2]; bool vis[MAXM+2]; long long dijk(int N, int s, int e) { memset(dist, 0x3f, sizeof dist); memset(vis, 0, sizeof vis); dist[s] = 0; for(int _=0; _<N; _++) { int mini = -1; long long minv = INF; for(int i=0; i<N; ++i) if(!vis[i] && minv>dist[i]) mini = i, minv = dist[i]; if(mini == -1) return -1; if(mini == e) return minv; vis[mini] = true; for(int i=0; i<N; ++i) dist[i] = min(dist[i], dist[mini]+cost[mini][i]); } return -1; } int main() { scanf("%d%d", &N, &M); for(int i=1; i<=M; ++i) { scanf("%d%d%d%d", T+i, L+i, R+i, C+i); --L[i]; //L[i] = 0, R[i] = N covers whole } memset(cost, 0x3f, sizeof cost); for(int i=1; i<=M; ++i) { if(L[i] == 0) cost[0][i] = C[i]; if(R[i] == N) cost[i][M+1] = 0; } for(int i=1; i<=M; ++i) { for(int j=1; j<=M; ++j) { if(i==j) continue; if(R[i] - abs(T[i]-T[j]) >= L[j]) cost[i][j] = C[j]; } } long long ans = dijk(M+2, 0, M+1); printf("%lld\n", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 101 ms | 196344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 107 ms | 196216 KB | Output is correct |
2 | Correct | 99 ms | 196216 KB | Output is correct |
3 | Correct | 113 ms | 196160 KB | Output is correct |
4 | Correct | 99 ms | 196216 KB | Output is correct |
5 | Correct | 100 ms | 196216 KB | Output is correct |
6 | Correct | 101 ms | 196344 KB | Output is correct |
7 | Correct | 97 ms | 196216 KB | Output is correct |
8 | Correct | 97 ms | 196216 KB | Output is correct |
9 | Correct | 100 ms | 196216 KB | Output is correct |
10 | Correct | 96 ms | 196216 KB | Output is correct |
11 | Correct | 100 ms | 196216 KB | Output is correct |
12 | Correct | 100 ms | 196216 KB | Output is correct |
13 | Correct | 96 ms | 196216 KB | Output is correct |
14 | Correct | 97 ms | 196216 KB | Output is correct |
15 | Correct | 96 ms | 196216 KB | Output is correct |
16 | Correct | 102 ms | 196216 KB | Output is correct |
17 | Correct | 99 ms | 196216 KB | Output is correct |
18 | Correct | 101 ms | 196220 KB | Output is correct |
19 | Correct | 98 ms | 196216 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 107 ms | 196216 KB | Output is correct |
2 | Correct | 99 ms | 196216 KB | Output is correct |
3 | Correct | 113 ms | 196160 KB | Output is correct |
4 | Correct | 99 ms | 196216 KB | Output is correct |
5 | Correct | 100 ms | 196216 KB | Output is correct |
6 | Correct | 101 ms | 196344 KB | Output is correct |
7 | Correct | 97 ms | 196216 KB | Output is correct |
8 | Correct | 97 ms | 196216 KB | Output is correct |
9 | Correct | 100 ms | 196216 KB | Output is correct |
10 | Correct | 96 ms | 196216 KB | Output is correct |
11 | Correct | 100 ms | 196216 KB | Output is correct |
12 | Correct | 100 ms | 196216 KB | Output is correct |
13 | Correct | 96 ms | 196216 KB | Output is correct |
14 | Correct | 97 ms | 196216 KB | Output is correct |
15 | Correct | 96 ms | 196216 KB | Output is correct |
16 | Correct | 102 ms | 196216 KB | Output is correct |
17 | Correct | 99 ms | 196216 KB | Output is correct |
18 | Correct | 101 ms | 196220 KB | Output is correct |
19 | Correct | 98 ms | 196216 KB | Output is correct |
20 | Correct | 290 ms | 196472 KB | Output is correct |
21 | Correct | 287 ms | 196216 KB | Output is correct |
22 | Correct | 247 ms | 196216 KB | Output is correct |
23 | Correct | 226 ms | 196216 KB | Output is correct |
24 | Correct | 175 ms | 196216 KB | Output is correct |
25 | Correct | 210 ms | 196216 KB | Output is correct |
26 | Correct | 204 ms | 196472 KB | Output is correct |
27 | Correct | 193 ms | 196344 KB | Output is correct |
28 | Correct | 181 ms | 196216 KB | Output is correct |
29 | Correct | 202 ms | 196216 KB | Output is correct |
30 | Correct | 142 ms | 196344 KB | Output is correct |
31 | Correct | 143 ms | 196344 KB | Output is correct |
32 | Correct | 228 ms | 196296 KB | Output is correct |
33 | Correct | 178 ms | 196216 KB | Output is correct |
34 | Correct | 302 ms | 196288 KB | Output is correct |
35 | Correct | 230 ms | 196220 KB | Output is correct |
36 | Correct | 176 ms | 196472 KB | Output is correct |
37 | Correct | 318 ms | 196368 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 101 ms | 196344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |