제출 #153824

#제출 시각아이디문제언어결과실행 시간메모리
153824Ruxandra985로봇 (IOI13_robots)C++14
100 / 100
1945 ms24224 KiB
#include <cstdio> #include <iostream> #include <algorithm> #include "robots.h" #include <vector> #include <queue> using namespace std; int ok (int gmax ,int a , int b , int t , int y[],int s[],vector <int> v[50010] ){ int i,j; /// pana acum am log 10^6 priority_queue <int> h,h2; for (i=0;i<=a;i++){ for (j=0;j<v[i].size();j++) h.push(s[v[i][j]]); if (i!=a){ for (j=1;j<=gmax && !h.empty();j++) h.pop(); /// cele mai mari gmax sizeuri le pun aici } } /// in h au ramas cele pe care trebuie tu sa le pui la robotii mici //if (gmax == 23) // printf ("%d ",h.size()); for (i=b-1;i>=0;i--){ if (h.empty()) return 1; if (h.top() > y[i]) return 0; for (j=1;j<=gmax && !h.empty();j++){ h.pop(); } } return h.empty(); } int putaway (int a , int b , int t , int x[],int y[],int w[],int s[]){ int maxw,maxs,i,k,st,dr,mid; vector <int> v[50010]; /// cazul cand nu se poate maxw = maxs = 0; for (i=0;i<a;i++){ x[i]--; maxw = max ( maxw , x[i] ); } for (i=0;i<b;i++){ y[i]--; maxs = max ( maxs , y[i] ); } for (i=0;i<t;i++){ if (w[i] > maxw && s[i] > maxs) /// nu se poate return -1; } /// stim ca se poate /// initial , le pun pe toate ca fiind pentru weak + un elem fictiv x[a] = 2000000000; sort (x , x + a); sort (y , y + b); k = 0; for (i=0;i<t;i++){ /// cel mai mic x in care pot sa o pun st = 0; dr = a; while (st<=dr){ mid = (st + dr)/2; if (x[mid] >= w[i]) dr = mid - 1; else st = mid + 1; } v[st].push_back(i); /// pe st poti sa o pui if (v[st].size() > k) k = v[st].size(); } st = 1; dr = k; while (st<=dr){ mid = (st + dr)/2; if (ok(mid ,a,b,t,y,s , v)) dr = mid - 1; else st = mid + 1; } return st; }

컴파일 시 표준 에러 (stderr) 메시지

robots.cpp: In function 'int ok(int, int, int, int, int*, int*, std::vector<int>*)':
robots.cpp:14:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (j=0;j<v[i].size();j++)
                  ~^~~~~~~~~~~~
robots.cpp:26:7: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
       if (h.empty())
       ^~
robots.cpp:28:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
         if (h.top() > y[i])
         ^~
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:71:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (v[st].size() > k)
             ~~~~~~~~~~~~~^~~
#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...