Submission #833073

#TimeUsernameProblemLanguageResultExecution timeMemory
833073HaroldVemenoRobots (IOI13_robots)C++17
76 / 100
3057 ms35584 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); multiset<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.insert(bt[j++]); for(int k = 0; k < m; ++k) { if(wst.empty()) break; D("erase") wst.erase(wst.begin()); } } while(j < ts) { wst.insert(bt[j++]); } D(j) D(wst.size()) vector<T> rst(rbegin(wst), rend(wst)); 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:70:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<T>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |             while(j < rst.size() && rst[j].s < sl[i]) {
      |                   ~~^~~~~~~~~~~~
robots.cpp:77:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<T>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |         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...