답안 #748972

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
748972 2023-05-27T08:26:19 Z Dan4Life 치료 계획 (JOI20_treatment) C++17
35 / 100
441 ms 355292 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
const int mxM = (int)5e3+10;
const int LINF = (int)1e18;
using pii = pair<int,int>;

int n, m, ans=LINF;
int dis[mxM], vis[mxM];
vector<pii> adj[mxM], v;
struct Project{ int t, l, r, c; } a[mxM];

int dijkstra(vector<pii> v){
	fill(dis,dis+m,LINF); fill(vis,vis+m,0); 
	for(auto [u,w] : v) dis[u]=w;
	for(int i = 0; i < n; i++){
		int mn = LINF, a = -1;
		for(int j = 0; j < m; j++)
			if(!vis[j] and mn>dis[j]) mn=dis[j],a=j;
		if(a==-1) break; vis[a]=1;
		for(auto [b,w]: adj[a])
			if(dis[a]+w < dis[b]) 
				dis[b]=dis[a]+w;
	}
	int d = LINF;
	for(int i = 0; i < m; i++) 
		if(a[i].r==n) d=min(d,dis[i]);
	return d;
}

int32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	for(int i = 0; i < m; i++) 
		cin >> a[i].t >> a[i].l >> a[i].r >> a[i].c;
	for(int i = 0; i < m; i++)
		for(int j = 0; j < m; j++)
			if(a[i].r-abs(a[i].t-a[j].t)>=a[j].l-1 and i!=j)
				adj[i].pb({j,a[j].c});
	for(int i = 0; i < m; i++) if(a[i].l==1) v.pb({i,a[i].c});
	ans = dijkstra(v);
	cout << (ans==LINF?-1:ans);
}

Compilation message

treatment.cpp: In function 'long long int dijkstra(std::vector<std::pair<long long int, long long int> >)':
treatment.cpp:21:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   21 |   if(a==-1) break; vis[a]=1;
      |   ^~
treatment.cpp:21:20: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   21 |   if(a==-1) break; vis[a]=1;
      |                    ^~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 1748 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 448 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 448 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 444 KB Output is correct
20 Correct 345 ms 245952 KB Output is correct
21 Correct 333 ms 245920 KB Output is correct
22 Correct 102 ms 5964 KB Output is correct
23 Correct 80 ms 5864 KB Output is correct
24 Correct 259 ms 174640 KB Output is correct
25 Correct 177 ms 117940 KB Output is correct
26 Correct 158 ms 112412 KB Output is correct
27 Correct 184 ms 138036 KB Output is correct
28 Correct 271 ms 173292 KB Output is correct
29 Correct 170 ms 116412 KB Output is correct
30 Correct 145 ms 131924 KB Output is correct
31 Correct 158 ms 140900 KB Output is correct
32 Correct 335 ms 226724 KB Output is correct
33 Correct 438 ms 355292 KB Output is correct
34 Correct 312 ms 226776 KB Output is correct
35 Correct 333 ms 226796 KB Output is correct
36 Correct 441 ms 354984 KB Output is correct
37 Correct 338 ms 226292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 1748 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -