Submission #833075

#TimeUsernameProblemLanguageResultExecution timeMemory
833075HaroldVemenoRobots (IOI13_robots)C++17
100 / 100
2269 ms32376 KiB
#include "robots.h" #include <bits/stdc++.h> #ifdef GUDEB #define D(x) cerr << #x << ": " << (x) << '\n'; #define ifdeb if(true) #else #define D(x) ; #define ifdeb if(false) #endif #define all(x) begin(x), end(x) using namespace std; using ull = unsigned long long; using ll = long long; // #define int ll; struct T { int w; int s; friend bool operator < (T a, T b) { return a.s < b.s; } }; int putaway(int wr, int sr, int ts, int wl[], int sl[], int w[], int s[]) { sort(wl, wl+wr); sort(sl, sl+sr); vector<T> bt(ts); for(int i = 0; i < ts; ++i) { bt[i] = {w[i], s[i]}; } sort(all(bt), [](T a, T b){return a.w < b.w;}); ll b = 0; ll e = 2001000000; while(b < e) { ll m = (b+e)/2; D(m); priority_queue<T> wst; int j = 0; for(int i = 0; i < wr; ++i) { D(wl[i]) D(bt[j].w) while(j < ts && bt[j].w < wl[i]) wst.push(bt[j++]); for(int k = 0; k < m; ++k) { if(wst.empty()) break; D("erase") wst.pop(); } } while(j < ts) { wst.push(bt[j++]); } D(j) D(wst.size()) vector<T> rst; while(!wst.empty()) { rst.push_back(wst.top()); wst.pop(); } reverse(all(rst)); ifdeb { for(auto[w, s] : rst) { cerr << w << ' ' << s << '\n'; } cerr << '\n' << '\n'; } j = 0; int rem = 0; for(int i = 0; i < sr; ++i) { D(sl[i]) while(j < rst.size() && rst[j].s < sl[i]) { ++j; ++rem; } rem = max(0ll, rem - m); D(rem); } if(rem == 0 && j == rst.size()) { e = m; } else { b = m+1; } } if(b > 2000000010) return -1; return b; }

Compilation message (stderr)

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:75:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<T>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |             while(j < rst.size() && rst[j].s < sl[i]) {
      |                   ~~^~~~~~~~~~~~
robots.cpp:82:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<T>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   82 |         if(rem == 0 && j == rst.size()) {
      |                        ~~^~~~~~~~~~~~~
#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...