이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#include "robots.h"
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define aint(a) (a).begin(), (a).end()
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll weak[200005],small[200005],a,b,t;
pair<ll,ll>r[200005];
ll check(ll x){
priority_queue<ll>q;
ll pos=0;
for(ll i=0;i<a;i++)
{
ll mx=weak[i];
ll cnt=0;
while(pos<t&&r[pos].f<mx){
q.push(r[pos].s);
pos++;
}
while(cnt<x&&!q.empty()){
q.pop();
cnt++;
}
}
for(ll i=pos;i<t;i++)
{
q.push(r[pos].s);
}
vector<ll>v;
while(!q.empty()){
v.pb(q.top());
q.pop();
}
reverse(v.begin(),v.end());
ll sz=v.size();
pos=0;
for(int i=0;i<b;i++)
{
ll mx=small[i];
ll cnt=0;
while(cnt<x&&pos<sz&&v[pos]<mx){
pos++;
cnt++;
}
}
if(pos>=sz){
return 1;
}else return 0;
}
ll bs(ll l,ll r){
if(l==r){
if(check(l)){
return l;
}else return -1;
}
ll mid=(l+r)/2;
if(check(mid)){
return bs(l,mid);
}else return (mid+1,r);
}
int putaway(int A,int B,int T,int X[],int Y[],int W[],int S[]){
a=A;
b=B;
t=T;
for(ll i=0;i<a;i++){
weak[i]=X[i];
}
for(ll i=0;i<b;i++)
{
small[i]=Y[i];
}
sort(weak,weak+a);
sort(small,small+b);
for(ll i=0;i<t;i++)
{
r[i]=mp(W[i],S[i]);
}
sort(r,r+t);
return bs(1,t);
}
/*
int32_t main(){
CODE_START;
*/
컴파일 시 표준 에러 (stderr) 메시지
robots.cpp: In function 'long long int bs(long long int, long long int)':
robots.cpp:74:18: warning: left operand of comma operator has no effect [-Wunused-value]
74 | }else return (mid+1,r);
| ~~~^~
# | 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... |