# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
1046959 |
2024-08-07T06:54:59 Z |
변재우(#11026) |
치료 계획 (JOI20_treatment) |
C++17 |
|
161 ms |
189500 KB |
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int Nmax=5010, INF=1e18;
int N, M, T[Nmax], L[Nmax], R[Nmax], C[Nmax], D[Nmax];
vector<int> adj[Nmax];
priority_queue<pair<int, int>> PQ;
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>N>>M;
for(int i=1; i<=M; i++) {
cin>>T[i]>>L[i]>>R[i]>>C[i];
if(L[i]==1) adj[0].push_back(i);
if(R[i]==N) adj[i].push_back(M+1);
}
for(int i=1; i<=M; i++) for(int j=1; j<=M; j++) if(i!=j) {
int r1=R[i]-max(0ll, T[j]-T[i]);
int l2=L[j]+max(0ll, T[i]-T[j]);
if(l2<=r1+1) adj[i].push_back(j);
}
fill(D+1, D+M+2, INF);
PQ.push({0, 0});
while(!PQ.empty()) {
int curr=PQ.top().second, dist=-PQ.top().first; PQ.pop();
if(dist!=D[curr]) continue;
for(int next:adj[curr]) if(D[next]>D[curr]+C[next]) D[next]=D[curr]+C[next], PQ.push({-D[next], next});
}
if(D[M+1]==INF) cout<<-1;
else cout<<D[M+1];
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
604 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
604 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
153 ms |
129620 KB |
Output is correct |
21 |
Correct |
152 ms |
129364 KB |
Output is correct |
22 |
Correct |
34 ms |
3408 KB |
Output is correct |
23 |
Correct |
33 ms |
3416 KB |
Output is correct |
24 |
Correct |
111 ms |
93264 KB |
Output is correct |
25 |
Correct |
63 ms |
64084 KB |
Output is correct |
26 |
Correct |
60 ms |
61264 KB |
Output is correct |
27 |
Correct |
68 ms |
74944 KB |
Output is correct |
28 |
Correct |
107 ms |
92752 KB |
Output is correct |
29 |
Correct |
63 ms |
63324 KB |
Output is correct |
30 |
Correct |
56 ms |
71248 KB |
Output is correct |
31 |
Correct |
61 ms |
76628 KB |
Output is correct |
32 |
Correct |
152 ms |
120660 KB |
Output is correct |
33 |
Correct |
161 ms |
189500 KB |
Output is correct |
34 |
Correct |
147 ms |
119888 KB |
Output is correct |
35 |
Correct |
158 ms |
120880 KB |
Output is correct |
36 |
Correct |
154 ms |
189012 KB |
Output is correct |
37 |
Correct |
144 ms |
119800 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |