# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1111591 |
2024-11-12T09:50:30 Z |
zhehan |
Fire (BOI24_fire) |
C++14 |
|
1 ms |
504 KB |
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int main()
{
int n,m,day_start=0,day_end,a,b;
cin>>n>>m;
day_end=m;
vector<ii> shifts;
for(int i=0;i<n;++i){
cin>>a>>b;
if(a>b){
a-=day_end;
shifts.push_back(ii(a,b));
}else{
shifts.push_back(ii(a,b));
}
}
sort(shifts.begin(),shifts.end());
priority_queue<ii,vector<ii>> pq;
int pointer=0;
int counter=0;
while(day_start<day_end&&pointer<n){
while(pointer<n&&shifts.at(pointer).first<=day_start){
pq.push(ii(shifts.at(pointer).second,shifts.at(pointer).first));
++pointer;
}
if(pq.empty()){
break;
}
day_start=max(day_start,pq.top().first);
if(pq.top().second<0){
day_end=min(day_end,m+pq.top().second);
}
++counter;
pq.pop();
}
if(day_start<day_end){
cout<<-1<<'\n';
return 0;
}
cout<<counter<<'\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |