이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
//Billions of bilious blue blistering barnacles in a thundering typhoon!
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
#pragma GCC target("avx2,fma")
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0) , cin.tie(0)
#define F first
#define S second
#define pb push_back
#define vll vector< ll >
#define vi vector< int >
#define pll pair< ll , ll >
#define pi pair< int , int >
#define all(s) s.begin() , s.end()
#define sz(s) s.size()
#define str string
#define md ((s + e) / 2)
#define mid ((l + r) / 2)
#define msdp(dp) memset(dp , -1 , sizeof dp)
#define mscl(dp) memset(dp , 0 , sizeof dp)
#define C continue
#define R return
#define B break
#define lx node * 2
#define rx node * 2 + 1
#define br(dosomething) {dosomething; break;}
#define co(dosomething) {dosomething ; continue;}
using namespace std;
typedef int ll;
ll q, dp[1500005] , a[1555555] , b[1555555], k, l, m, n, o, p;
map < ll , ll > mp;
vll adj[555555];
const ll mod = 1e9+7;
str s ;
pll c1[1555555] , c2[1555555] ;
pll op[1555555] ;
ll n1 , n2 ;
bool ok(ll cnt){
for(ll i = 0 ; i < n ; i++)dp[i] = 0 ;
priority_queue < pll > se ;
ll j = 0 ;
m = n ;
for(ll i = 0 ; i < n1 ; i++){
while(j < n){
if(dp[c1[j].S])co(j++) ;
if(c1[j].F >= a[i])B ;
se.push({op[c1[j].S].S , c1[j].S}) ;
j++ ;
}
ll cur = cnt ;
while(cur > 0 && !se.empty()){
pll op = se.top() ;
se.pop() ;
m-- ;
dp[op.S] = 1 ;
cur-- ;
}
}
if(!m)R 1 ;
if(!n2)R 0 ;
j = 0 ;
while(!se.empty())se.pop() ;
for(ll i = 0 ; i < n2 ; i++){
while(j < n){
if(dp[c2[j].S])co(j++) ;
if(c2[j].F >= b[i])B ;
se.push({op[c2[j].S].F , c2[j].S}) ;
j++ ;
}
ll cur = cnt ;
while(cur > 0 && !se.empty()){
pll op = se.top() ;
se.pop() ;
m-- ;
dp[op.S] = 1 ;
cur-- ;
}
}
R !m ;
}
int putaway(int A, int bb, int T, int X[], int Y[], int W[], int S[]) {
n = T ;
n1 = A , n2 = bb ;
for(ll i = 0 ; i < T ; i++){
c1[i] = {W[i] , i} ;
c2[i] = {S[i] , i} ;
op[i] = {W[i] , S[i]} ;
}
for(ll i = 0 ; i < n1 ; i++){
a[i] = X[i] ;
}
for(ll i = 0 ; i < n2 ; i++){
b[i] = Y[i] ;
}
sort(c1 , c1 + T) ;
sort(c2 , c2 + T) ;
if(n1 > 0)sort(a , a + A) ;
if(n2 > 0)sort(b , b + bb) ;
if(!ok(n))R -1 ;
ll l = 0 , r = T + 1 ;
while(r - l > 1){
if(ok(mid))r = mid ;
else l = mid ;
}
R 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... |