답안 #423935

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
423935 2021-06-11T14:16:06 Z jamezzz 치료 계획 (JOI20_treatment) C++17
4 / 100
219 ms 17368 KB
#include <bits/stdc++.h>
using namespace std;

#define sf scanf
#define pf printf
#define fi first
#define se second
#define pb emplace_back
#define LINF 1023456789123456789
#define all(x) x.begin(),x.end()
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,int> li;

#define maxn 200005

int n,m,t[maxn],l[maxn],r[maxn],c[maxn];
ll dist[maxn];
vector<int> d;
vector<ii> AL[maxn];
priority_queue<li,vector<li>,greater<li>> pq;

int main(){
	sf("%d%d",&n,&m);
	d.pb(1);d.pb(n+1);
	for(int i=0;i<m;++i){
		sf("%d%d%d%d",&t[i],&l[i],&r[i],&c[i]);
		d.pb(l[i]);d.pb(r[i]+1);
	}
	sort(all(d));
	d.erase(unique(all(d)),d.end());
	for(int i=0;i<m;++i){
		l[i]=lower_bound(all(d),l[i])-d.begin();
		r[i]=lower_bound(all(d),r[i]+1)-d.begin();
		AL[l[i]].pb(r[i],c[i]);
	}
	n=d.size();
	for(int i=1;i<n;++i){
		dist[i]=LINF;
		AL[i].pb(i-1,0);
	}
	dist[0]=0;
	pq.push(li(0,0));
	while(!pq.empty()){
		ll d;int u;tie(d,u)=pq.top();pq.pop();
		if(d>dist[u])continue;
		for(ii pr:AL[u]){
			if(dist[pr.fi]>dist[u]+pr.se){
				dist[pr.fi]=dist[u]+pr.se;
				pq.push(li(dist[pr.fi],pr.fi));
			}
		}
	}
	if(dist[n-1]==LINF)pf("-1\n");
	else pf("%lld\n",dist[n-1]);
}

/*
10 5
1 5 10 3
1 1 6 5
1 2 8 3
1 6 10 4
1 1 3 1
*/

Compilation message

treatment.cpp: In function 'int main()':
treatment.cpp:24:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  sf("%d%d",&n,&m);
      |    ^
treatment.cpp:27:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |   sf("%d%d%d%d",&t[i],&l[i],&r[i],&c[i]);
      |     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 108 ms 11192 KB Output is correct
2 Correct 128 ms 11268 KB Output is correct
3 Correct 88 ms 10584 KB Output is correct
4 Correct 89 ms 10552 KB Output is correct
5 Correct 54 ms 8236 KB Output is correct
6 Correct 59 ms 8388 KB Output is correct
7 Correct 67 ms 8832 KB Output is correct
8 Correct 54 ms 8336 KB Output is correct
9 Correct 60 ms 8340 KB Output is correct
10 Correct 69 ms 9156 KB Output is correct
11 Correct 169 ms 14008 KB Output is correct
12 Correct 147 ms 14652 KB Output is correct
13 Correct 166 ms 16668 KB Output is correct
14 Correct 219 ms 16696 KB Output is correct
15 Correct 165 ms 15188 KB Output is correct
16 Correct 156 ms 17368 KB Output is correct
17 Correct 159 ms 17332 KB Output is correct
18 Correct 148 ms 16400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Incorrect 3 ms 4940 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Incorrect 3 ms 4940 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 108 ms 11192 KB Output is correct
2 Correct 128 ms 11268 KB Output is correct
3 Correct 88 ms 10584 KB Output is correct
4 Correct 89 ms 10552 KB Output is correct
5 Correct 54 ms 8236 KB Output is correct
6 Correct 59 ms 8388 KB Output is correct
7 Correct 67 ms 8832 KB Output is correct
8 Correct 54 ms 8336 KB Output is correct
9 Correct 60 ms 8340 KB Output is correct
10 Correct 69 ms 9156 KB Output is correct
11 Correct 169 ms 14008 KB Output is correct
12 Correct 147 ms 14652 KB Output is correct
13 Correct 166 ms 16668 KB Output is correct
14 Correct 219 ms 16696 KB Output is correct
15 Correct 165 ms 15188 KB Output is correct
16 Correct 156 ms 17368 KB Output is correct
17 Correct 159 ms 17332 KB Output is correct
18 Correct 148 ms 16400 KB Output is correct
19 Correct 3 ms 4940 KB Output is correct
20 Incorrect 3 ms 4940 KB Output isn't correct
21 Halted 0 ms 0 KB -