이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "robots.h"
using namespace std;
#ifdef LOCAL
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
cerr<<vars<<" = ";
string delim="";
(...,(cerr<<delim<<values,delim=", "));
cerr<<"\n";
}
#else
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {}
#endif
#define pb push_back
#define sz(x) (int)(x.size())
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> inline void maxa(T& a,T b){a=max(a,b);}
template<typename T> inline void mina(T& a,T b){a=min(a,b);}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mxN=1e5+5; //make sure this is right
const int mod=1e9+7;
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]){
int ans=0; int active=0; int cnt=0;
vector<pii> toys;
priority_queue<int> small,weak;
for(int i=0;i<A;i++)
weak.push(X[i]);
for(int i=0;i<B;i++)
small.push(Y[i]);
for(int i=0;i<T;i++)
toys.pb({W[i],S[i]});
sort(toys.begin(),toys.end(),[&](auto a,auto b){return a.first>b.first;});
for(auto &[w,s]:toys){
while(sz(weak) && w<weak.top()){
if(active && cnt){
cnt=max(0,cnt-2*(active-1));
ans+=(cnt+active-1)/active;
deb(cnt,active,ans);
}
cnt=0;
active++; weak.pop();
}
while(sz(small) && s<small.top()){
if(active && cnt){
cnt=max(0,cnt-2*(active-1));
ans+=(cnt+active-1)/active;
deb(cnt,active,ans);
}
cnt=0;
active++; small.pop();
}
deb(w,s,active);
cnt++;
if(active==0)
return -1;
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:45:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
45 | for(auto &[w,s]:toys){
| ^
# | 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... |