이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x) cerr<< #x <<" = "<< x<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
vector<int>v;
const ll B=1e15;
struct tree{
ll mn[MAXN<<2];
tree(){
for(int i=0;i<MAXN*4;i++)
mn[i]=B;
}
void upd(int p,ll v,int nd,int x,int y){
if(x==y){
umin(mn[nd],v);
return;
}
int mid=(x+y)>>1;
if(p<=mid)
upd(p,v,nd<<1,x,mid);
else
upd(p,v,nd<<1|1,mid+1,y);
mn[nd]=min(mn[nd<<1],mn[nd<<1|1]);
}
ll tap(int l,int r,int nd,int x,int y){
if(l>y or x>r)
return B;
if(l<=x and y<=r)
return mn[nd];
int mid=(x+y)>>1;
return min(tap(l,r,nd<<1,x,mid),tap(l,r,nd<<1|1,mid+1,y));
}
}L,R;
int a[MAXN],b[MAXN],c[MAXN],d[MAXN];
int main(){
//~ freopen("file.in", "r", stdin);
int n,m;
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
v.pb(c[i]);
}
v.pb(1);v.pb(m);sort(all(v));
v.erase(unique(all(v)),v.end());int sz=v.size();
L.upd(1,0,1,1,sz);
R.upd(sz,0,1,1,sz);
ll ans=B;
for(int i=1;i<=n;i++){
int pos=lower_bound(all(v),c[i])-v.begin()+1;
int x=lower_bound(all(v),a[i])-v.begin()+1;
int y=upper_bound(all(v),b[i])-v.begin();
ll c1=L.tap(x,y,1,1,sz);
ll c2=R.tap(x,y,1,1,sz);
umin(ans,c1+c2+d[i]);
L.upd(pos,c1+d[i],1,1,sz);
R.upd(pos,c2+d[i],1,1,sz);
}
if(ans==B)
ans=-1;
printf("%lld\n",ans);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
pinball.cpp: In function 'int main()':
pinball.cpp:53:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&m);
~~~~~^~~~~~~~~~~~~~
pinball.cpp:55:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |