Submission #1060627

#TimeUsernameProblemLanguageResultExecution timeMemory
1060627vjudge1Robots (IOI13_robots)C++17
0 / 100
1 ms12636 KiB
#include "robots.h" #include<bits/stdc++.h> using namespace std; typedef pair<int, int> ii; typedef long long ll; typedef pair<long long, long long> pll; typedef long double ld; typedef vector<int> vi; typedef vector<string> vs; #define pb push_back #define fi first #define se second #define whole(v) v.begin(), v.end() #define rwhole(v) v.rbegin(), v.rend() #define inf INT_MAX/2 #define fro front int A, B, T; int x[1000000]; int y[1000000]; int w[1000000]; int s[1000000]; vector<ii> z; bool f(int n){ int j = 0; int i = 0; int cnt = 0; priority_queue<int> q; for(j; j < A; ++j){ while(z[i].fi >= x[j]){ q.push(z[i].se); ++i; if(i >= z.size()){ break; } cnt++; } if(j > 0) cnt -= n; } vector<int> ne; for(int k = 0; k < cnt; ++k){ ne.pb(q.top()); q.pop(); } sort(whole(ne)); i = 0; j = 0; for(j; j < B; ++j){ int cn = 0; while(ne[i] < y[j]){ cn++; cnt--; ++i; if(i >= ne.size()){ break; } if(cn == n){ break; } } if(i >= ne.size()){ break; } } if(cnt > 0){ return 0; }else{ return 1; } } int putaway(int a, int b, int t, int X[], int Y[], int W[], int S[]){ for(int i = 0; i < a; ++i){ x[i] = X[i]; } for(int i = 0; i < b; ++i){ y[i] = Y[i]; } for(int i = 0; i < t; ++i){ w[i] = W[i]; } for(int i = 0; i < t; ++i){ s[i] = S[i]; } sort(x, x+a); sort(y, y+b); reverse(x, x+a); A = a; B = b; T = t; for(int i = 0; i < t; ++i){ z.pb(ii(w[i], s[i])); if(w[i] >= x[0] && s[i] >= y[0]){ return -1; } } sort(rwhole(z)); int lo = 0; int hi = t + 2; while(hi - lo > 1){ int mi = lo + (hi - lo) / 2; if(f(mi)){ hi = mi; }else{ lo = mi; } } return hi; }

Compilation message (stderr)

robots.cpp: In function 'bool f(int)':
robots.cpp:33:9: warning: statement has no effect [-Wunused-value]
   33 |     for(j; j < A; ++j){
      |         ^
robots.cpp:37:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |             if(i >= z.size()){
      |                ~~^~~~~~~~~~~
robots.cpp:54:9: warning: statement has no effect [-Wunused-value]
   54 |     for(j; j < B; ++j){
      |         ^
robots.cpp:60:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |             if(i >= ne.size()){
      |                ~~^~~~~~~~~~~~
robots.cpp:67:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |         if(i >= ne.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...