제출 #1082381

#제출 시각아이디문제언어결과실행 시간메모리
1082381modwwe로봇 (IOI13_robots)C++17
100 / 100
2240 ms30376 KiB
#include "robots.h"
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
//#define int long long
//#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define NHP     ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe  int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".ans","w",stdout)
#define pb push_back
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
#define getchar_unlocked getchar

inline int scan()
{
    char c = getchar_unlocked();
    int x = 0;
    while(c<'0'||c>'9')
    {
        c=getchar_unlocked();
    }
    while(c>='0'&&c<='9')
    {
        x=(x<<1)+(x<<3)+c-'0';
        c=getchar_unlocked();
    }
    return x;
}

void phongbeo();
const int inf=1e9;
const int mod2=1e9+9;
const int  mod1=998244353;
struct icd
{
    long double a;
    int b;
};
struct ib
{
    int a;
    int b;
};
struct ic
{
    int a,b,c;
};
struct id
{
    int a,b,c,d;
};
struct ie
{
    int a,b,c,d,e;

};

int n,m,s1,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,dem4,l,r,mid,l2,r2;
int  i,s10,s12;
int kk;
int el=29;

vector<int> v,v2;
set<int> s;
set<int> s2;
bool c[1000001];
ib a[1000001];
unordered_map<int,int> cnt;
unordered_map<int,int> cnt2;
bool cmp(ib a,ib b)
{
    return a.b>b.b;
}
bool check(int x)
{
    for(auto f:v)
        cnt[f]=0;
    for(auto f:v2)
        cnt2[f]=0;
    for(auto f:v)
        s.insert(f),cnt[f]+=x;
    for(auto f:v2)
        s2.insert(f),cnt2[f]+=x;
    for(int i=1; i<=k; i++)
        c[i]=0;
    for(int i=1; i<=k; i++)
    {
        set<int>::iterator sx = s.lower_bound(a[i].a);
        if(sx==s.end()) continue;
        cnt[*sx]--;
        c[i]=1;
        if(cnt[*sx]==0) s.erase(sx);
    }
    for(int i=1; i<=k; i++)
    {
        if(c[i]) continue;
        set<int>::iterator sx = s2.lower_bound(a[i].b);
        if(sx==s2.end()) {
                return 0;}
        cnt2[*sx]--;
        if(cnt2[*sx]==0) s2.erase(sx);
    }
    return 1;
}
int putaway(int n, int m, int T, int X[], int Y[], int W[], int S[])
{
    k=T;
    for(int i=1; i<=n; i++)
        v.pb(X[i-1]-1);
    for(int i=1; i<=m; i++)
       v2.pb(Y[i-1]-1);
    for(int i=1; i<=k; i++)
      a[i].a=W[i-1],a[i].b=S[i-1];
    sort(a+1,a+1+k,cmp);
    l=max(1,k/(n+m));
    r=k;
while(l<=r)
{
    int mid=l+r>>1;
     if(check(mid))r=mid-1;
     else l=mid+1;
}
if(r==k) return -1;
 return r+1;
}

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

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:125:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  125 |     int mid=l+r>>1;
      |             ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...