이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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){
while(pointer<n&&shifts.at(pointer).first<=day_start+1){
pq.push(ii(shifts.at(pointer).second,shifts.at(pointer).first));
++pointer;
}
day_start=pq.top().first;
if(pq.top().second<0){
day_end=min(day_end,m-pq.top().second);
}
++counter;
pq.pop();
}
cout<<counter<<'\n';
return 0;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |