#include <bits/stdc++.h>
using namespace std;
#define int long long
struct plan{
int t,l,r,c;
plan(int t,int l,int r,int c):t(t),l(l-1),r(r+1),c(c){}
bool operator<(const plan& other)const{
return c<other.c;
}
};
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,m;
cin >> n >> m;
list<plan> plans;
priority_queue<pair<int,plan>> q;
for(int i=1;i<=m;i++){
int t,l,r,c;cin>>t>>l>>r>>c;
if(l==1) q.emplace(-c,plan(t,l,r,c));
else plans.emplace_back(t,l,r,c);
}
while(!q.empty()){
auto [dist,curr] = q.top();q.pop();
if(curr.r==n+1){
cout << -dist << '\n';
return 0;
}
auto iter = plans.begin();
while(iter!=plans.end()){
if(iter->t+iter->l<curr.r+curr.t and curr.t-curr.r<iter->t-iter->l){
q.emplace(dist-iter->c,*iter);
iter=plans.erase(iter);
} else iter++;
}
}
cout << "-1\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3051 ms |
9812 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 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 |
456 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 |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
360 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 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 |
456 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 |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
360 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
22 ms |
604 KB |
Output is correct |
21 |
Correct |
19 ms |
860 KB |
Output is correct |
22 |
Correct |
35 ms |
860 KB |
Output is correct |
23 |
Correct |
30 ms |
860 KB |
Output is correct |
24 |
Correct |
4 ms |
1116 KB |
Output is correct |
25 |
Correct |
36 ms |
976 KB |
Output is correct |
26 |
Correct |
21 ms |
860 KB |
Output is correct |
27 |
Correct |
20 ms |
860 KB |
Output is correct |
28 |
Correct |
6 ms |
980 KB |
Output is correct |
29 |
Correct |
27 ms |
848 KB |
Output is correct |
30 |
Correct |
2 ms |
860 KB |
Output is correct |
31 |
Correct |
2 ms |
860 KB |
Output is correct |
32 |
Correct |
2 ms |
1116 KB |
Output is correct |
33 |
Correct |
2 ms |
1116 KB |
Output is correct |
34 |
Correct |
31 ms |
860 KB |
Output is correct |
35 |
Correct |
2 ms |
1112 KB |
Output is correct |
36 |
Correct |
2 ms |
1200 KB |
Output is correct |
37 |
Correct |
29 ms |
924 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3051 ms |
9812 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |