| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 462023 | Jasiekstrz | Autobahn (COI21_autobahn) | C++17 | 89 ms | 6604 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N=1e5;
vector<pair<int,int>> ev;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,k,x;
cin>>n>>k>>x;
for(int i=1;i<=n;i++)
{
int l,r,t;
cin>>l>>t>>r;
if(l+t<=r)
{
ev.emplace_back(l+t,0);
ev.emplace_back(r+1,1);
}
ev.emplace_back(l,2);
ev.emplace_back(r+1,3);
}
sort(ev.begin(),ev.end());
int l=-x,r=0;
int cntl=0,cntr=0;
int opl=0,opr=0;
long long ans=0,tmp=0;
for(int i=0,j=0;i<ev.size();)
{
if(j>=ev.size() || ev[i].fi-l<ev[j].fi-r)
{
long long d=ev[i].fi-l;
if(opr>=k)
tmp+=d*cntr;
if(opl>=k)
tmp-=d*cntl;
l+=d;
r+=d;
if(ev[i].se==0)
cntl++;
else if(ev[i].se==1)
cntl--;
else if(ev[i].se==2)
opl++;
else
opl--;
i++;
}
else
{
long long d=ev[j].fi-r;
if(opr>=k)
tmp+=d*cntr;
if(opl>=k)
tmp-=d*cntl;
l+=d;
r+=d;
if(ev[j].se==0)
cntr++;
else if(ev[j].se==1)
cntr--;
else if(ev[j].se==2)
opr++;
else
opr--;
j++;
}
//cerr<<l<<" "<<r<<" "<<tmp<<"\n";
ans=max(ans,tmp);
}
cout<<ans<<"\n";
return 0;
}
컴파일 시 표준 에러 (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... | ||||
