제출 #784794

#제출 시각아이디문제언어결과실행 시간메모리
784794dungz로봇 (IOI13_robots)C++17
컴파일 에러
0 ms0 KiB
#pragma GCC optimize ("O2") #include<bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define endl '\n' #define task "task" #define task "task" #define prll pair<ll,ll> #define pb push_back #define ld long double #define int ll const ll MIN=-1e18,MAX=1e18,MOD=1e9+7; int a[50005],b[50005],c[50005]; pair<int,int> q[1000005]; vector<int> f[50005]; int f3[50005],f2[50005]; int n,m,t; bool check(int x) { for(int i=1;i<=m;i++) { f3[i]=f2[i]; } priority_queue<int,vector<int>,greater<int>> pq; int occ=0; for(int i=n;i>=1;i--) { int need=f[i].size(); int rem=(n-i+1)*x-occ; for(auto j:f[i]) pq.push(q[j].se); if(need>rem) { while(need>rem) { int top=pq.top(); pq.pop(); int l=1,r=m,tob=-1; while(l<=r) { int mid=(r+l)/2; if(b[mid]>top) { tob=mid; r=mid-1; } else l=mid+1; } if(tob==-1) return 0; f3[tob]+=1; need--; } occ=(n-i+1)*x; } else { occ+=need; } } occ=0; for(int i=m;i>=1;i--) { int need=f3[i]; int rem=(m-i+1)*x-occ; if(need>rem) return 0; occ+=need; } return 1; } signed main(){ #ifndef ONLINE_JUDGE freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); #endif ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>n>>m>>t; for(int i=1;i<=n;i++) { cin>>a[i]; } for(int i=1;i<=m;i++) { cin>>b[i]; } sort(a+1,a+1+n); sort(b+1,b+1+m); for(int i=1;i<=t;i++) { cin>>q[i].fi>>q[i].se; } for(int i=1;i<=t;i++) { if(q[i].fi<a[n]) c[i]+=1; if(q[i].se<b[m]) c[i]+=2; if(c[i]==0) { cout<<-1; return 0; } } for(int i=1;i<=t;i++) { if(c[i]==2) continue; int l=1,r=n,pos=-1; while(l<=r) { int mid=(l+r)/2; if(a[mid]>=q[i].fi) { pos=mid; r=mid-1; } else l=mid+1; } // cout<<q[i].fi<<" "<<pos<<endl; f[pos].push_back(i); } for(int i=1;i<=t;i++) { if(c[i]!=2) continue; int l=1,r=m,pos=-1; while(l<=r) { int mid=(l+r)/2; if(b[mid]>=q[i].se) { pos=mid; r=mid-1; } else l=mid+1; } f2[pos]+=1; } int l=1,r=t,ans=-1; while(l<=r) { int mid=(l+r)/2; if(check(mid)) { ans=mid; r=mid-1; } else l=mid+1; } cout<<ans; } /* */

컴파일 시 표준 에러 (stderr) 메시지

robots.cpp: In function 'int main()':
robots.cpp:73:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   73 |      freopen (task".inp", "r", stdin);
      |      ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
robots.cpp:74:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   74 |      freopen (task".out", "w", stdout);
      |      ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cc6ZEaNE.o: in function `main':
robots.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccMqsbSH.o:grader.c:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccMqsbSH.o: in function `main':
grader.c:(.text.startup+0x1b1): undefined reference to `putaway'
collect2: error: ld returned 1 exit status