Submission #993350

#TimeUsernameProblemLanguageResultExecution timeMemory
993350emad234Robots (IOI13_robots)C++17
100 / 100
1400 ms19208 KiB
#include "bits/stdc++.h" #define F first #define S second #define ll long long #define pii pair<int,int> const int mxN = 5e5 + 5; const int mod = 1e9 + 7; using namespace std; #ifndef __ROBOTS_H__ #define __ROBOTS_H__ #ifdef __cplusplus extern "C" { #endif vector<pii>v; int w[mxN],s[mxN]; int a,b; bool solve(int m){ priority_queue<int>q; int i = 0; for(auto x : v){ while(x.F >= w[i] && i < a){ int t = m; while(t-- && q.size()) q.pop(); i++; } q.push(x.S); } for(i; i < a;i++) { int t = m; while(t-- && q.size()) q.pop(); } i = 0; for(i;i < b;i++){ int t = m; while(t-- && q.size() && q.top() < s[i]) q.pop(); } return q.empty(); } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]){ a = A; b = B; for(int i = 0;i < A;i++) w[i] = X[i]; for(int i = 0;i < B;i++) s[i] = Y[i]; sort(w,w + a); sort(s,s + b,greater<>()); v.clear(); for(int i = 0;i < T;i++) v.push_back({W[i],S[i]}); sort(v.begin(),v.end()); int l = 1,r = T * 5; int md; int ans = -1; while(l < r){ md = (l + r) / 2; if(solve(md)){ ans = md; r = md; }else l = md + 1; } return ans; } #ifdef __cplusplus } #endif #endif /* __ROBOTS_H__ */

Compilation message (stderr)

robots.cpp: In function 'bool solve(int)':
robots.cpp:29:9: warning: statement has no effect [-Wunused-value]
   29 |     for(i; i < a;i++) {
      |         ^
robots.cpp:34:9: warning: statement has no effect [-Wunused-value]
   34 |     for(i;i < b;i++){
      |         ^
#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...