# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
423827 | tqbfjotld | 치료 계획 (JOI20_treatment) | C++14 | 319 ms | 185924 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
int T[5005];
int L[5005];
int R[5005];
int C[5005];
vector<int> adjl[5005];
int dist[5005];
main(){
int n,m;
scanf("%lld%lld",&n,&m);
for (int x = 0; x<m; x++){
scanf("%lld%lld%lld%lld",&T[x],&L[x],&R[x],&C[x]);
}
for (int x = 0; x<m; x++){
for (int y = 0; y<m; y++){
if (T[y]>T[x]){
if (L[x]-T[x]-1<=R[y]-T[y]){
adjl[x].push_back(y);
}
}
else{
if (L[x]+T[x]-1<=R[y]+T[y]){
adjl[x].push_back(y);
}
}
}
}
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > pq;
for (int x = 0; x<m; x++){
if (R[x]==n){
dist[x] = C[x];
pq.push({C[x],x});
}
else{
dist[x] = 999999999999999999LL;
}
}
while (!pq.empty()){
int node = pq.top().second;
int d = pq.top().first;
pq.pop();
if (d>dist[node]) continue;
for (auto x : adjl[node]){
if (d+C[x]<dist[x]){
// printf("node %lld go to %lld\n",node,x);
dist[x] = d+C[x];
pq.push({d+C[x],x});
}
}
}
int ans = 999999999999999999LL;
for (int x = 0; x<m; x++){
if (L[x]==1){
ans = min(ans,dist[x]);
}
}
printf("%lld",ans==999999999999999999LL?-1LL:ans);
}
컴파일 시 표준 에러 (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... |