Submission #1060647

#TimeUsernameProblemLanguageResultExecution timeMemory
1060647vjudge1Robots (IOI13_robots)C++17
0 / 100
10 ms21356 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[1000005]; int y[1000005]; int w[1000005]; int s[1000005]; vector<ii> z; bool f(int n){ int j = 0; int i = 0; vector<int> ne; priority_queue<int, vector<int>, greater<int>> q; for(j; j <= A; ++j){ while(i < z.size() && z[i].fi >= x[j]){ q.push(z[i].se); ++i; } while(q.size() > j * n){ ne.pb(q.top()); q.pop(); } } sort(whole(ne)); i = 0; j = 0; int cnt = ne.size(); 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[b-1]){ 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; } /*int main(){ int a = 3; int b = 2; int t = 10; int X[] = {6, 2, 9}; int Y[] = {4, 7}; int W[] = {4, 8, 2, 7, 1, 5, 3, 8, 7, 10}; int S[] = {6, 5, 3, 9, 8, 1, 3, 7, 6, 5}; cout << putaway(a, b, t, X, Y, W, S) << endl; }*/

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:34:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         while(i < z.size() && z[i].fi >= x[j]){
      |               ~~^~~~~~~~~~
robots.cpp:38:24: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int, std::vector<int>, std::greater<int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |         while(q.size() > j * n){
      |               ~~~~~~~~~^~~~~~~
robots.cpp:47:9: warning: statement has no effect [-Wunused-value]
   47 |     for(j; j <= B; ++j){
      |         ^
robots.cpp:53:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |             if(i >= ne.size()){
      |                ~~^~~~~~~~~~~~
robots.cpp:60:14: 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()){
      |            ~~^~~~~~~~~~~~
#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...