Submission #1001158

#TimeUsernameProblemLanguageResultExecution timeMemory
1001158ByeWorldRobots (IOI13_robots)C++14
100 / 100
1948 ms52212 KiB
#include "robots.h" #include <bits/stdc++.h> // #pragma GCC optimize("O3", "unroll-loops") // #define ll long long #define pb push_back #define fi first #define se second #define lf (id<<1) #define rg ((id<<1)|1) #define md ((l+r)>>1) #define ld long double using namespace std; typedef pair<int,int> pii; typedef pair<pii, int> ipii; const int MAXN = 1e6+30; const int INF = 1e9+10; const int LOG = 19; const int MOD = 1e9+7; const int SQRT = 450; // 3, -1 int a, b, t; int x[MAXN], y[MAXN], w[MAXN], s[MAXN]; vector <int> wei, siz, vec[MAXN]; // vec group int cw[MAXN], cs[MAXN]; bool cek(int want){ set <pii> can; for(int i=1; i<=a; i++){ cw[i] = want; can.insert({x[i], i}); } long long ext = 0; for(int i=wei.size(); i>=1; i--){ // dari wei tertinggi // vec isinya w[i] for(auto W : vec[i]){ // cek can terdekat, dari siz auto up = can.lower_bound(pii(W, -1)); if(up != can.end()){ int idx = (*up).se; cw[idx]--; if(cw[idx] == 0) can.erase(up); // invalid } else { // gk bisa kurangin ext, cek neg ext--; if(ext < 0) return 0; } } ext += want; } return 1; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { // cout << "masuk\n"; a = A; b = B; t = T; for(int i=1; i<=a; i++){ x[i] = X[i-1]; x[i]--; } sort(x+1, x+a+1); for(int i=1; i<=b; i++) siz.pb(y[i]); siz.pb(-1); sort(siz.begin(), siz.end()); for(int i=1; i<=b; i++){ y[i] = Y[i-1]; y[i]--; } sort(y+1, y+b+1); for(int i=1; i<=b; i++) wei.pb(y[i]); wei.pb(-1); sort(wei.begin(), wei.end()); for(int i=1; i<=t; i++){ w[i] = W[i-1]; s[i] = S[i-1]; int idx = lower_bound(wei.begin(), wei.end(), s[i]) - wei.begin(); vec[idx].pb(w[i]); } for(int i=1; i<=wei.size(); i++) sort(vec[i].rbegin(), vec[i].rend()); int l=1, r=MAXN, mid=0, cnt=-1; while(l<=r){ mid = md; if(cek(mid)){ r = mid-1; cnt = mid; } else l = mid+1; } return cnt; }

Compilation message (stderr)

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:77:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |  for(int i=1; i<=wei.size(); i++) sort(vec[i].rbegin(), vec[i].rend());
      |               ~^~~~~~~~~~~~
#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...