# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
423927 | jamezzz | 치료 계획 (JOI20_treatment) | C++17 | 3073 ms | 16892 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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<ii,vector<ii>,greater<ii>> 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
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |