제출 #918450

#제출 시각아이디문제언어결과실행 시간메모리
918450Macker로봇 (IOI13_robots)C++14
76 / 100
3059 ms37144 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; #define all(v) v.begin(), v.end() bool used[1000005]; int tt; vector<pair<int, int>> wi; vector<int> x, y; bool can(int t, int* W, int* S){ multimap<int, int> sicur; memset(used, 0, 1000005); int cnt = 0, j = 0; for (auto &i : wi) { while(j < x.size() && i.first >= x[j]){ cnt = 0; while(cnt < t && sicur.size()){ int k = (*--sicur.end()).second; used[k] = true; sicur.erase(--sicur.end()); cnt++; } j++; } sicur.insert({S[i.second], i.second}); } for (int i = j; i < x.size(); i++) { cnt = 0; while(cnt < t && sicur.size()){ int k = (*--sicur.end()).second; used[k] = true; sicur.erase(--sicur.end()); cnt++; } } vector<int> ss; for (int i = 0; i < tt; i++) { if(!used[i]) ss.push_back(S[i]); } if(ss.empty()) return 1; sort(all(ss), greater<int>()); j = 0; for (int i = y.size() - 1; i >= 0; i--) { cnt = 0; while(cnt < t){ if(ss[j] < y[i]) { j++; if(j >= ss.size()) return 1; cnt++; } else return 0; } } return 0; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { tt = T; for (int i = 0; i < T; i++) { wi.push_back({W[i], i}); } sort(all(wi)); for (int i = 0; i < A; i++) x.push_back(X[i]); for (int i = 0; i < B; i++) y.push_back(Y[i]); sort(all(x)); sort(all(y)); int l = 0, r = T + 1, mid; while(l < r){ mid = (l + r) / 2; if(can(mid, W, S)) r = mid; else l = mid + 1; } if(r == T + 1) return -1; return r; }

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

robots.cpp: In function 'bool can(int, int*, int*)':
robots.cpp:19:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |         while(j < x.size() && i.first >= x[j]){
      |               ~~^~~~~~~~~~
robots.cpp:32:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (int i = j; i < x.size(); i++) {
      |                     ~~^~~~~~~~~~
robots.cpp:55:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |                 if(j >= ss.size()) return 1;
      |                    ~~^~~~~~~~~~~~
#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...