제출 #722848

#제출 시각아이디문제언어결과실행 시간메모리
722848joelgun14로봇 (IOI13_robots)C++17
90 / 100
3015 ms44012 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { // bsta // cari max vector<pair<int, int>> a; sort(X, X + A); sort(Y, Y + B); for(int i = 0; i < T; ++i) { a.push_back(make_pair(W[i], S[i])); } int l = 1, r = T, ans = -1; sort(a.begin(), a.end()); while(l <= r) { int mid = (l + r) / 2; // try max mid // putaway // ambil dr w terbesar yg bs diambil s nya multiset<int> avail; // x -> weight limit // y -> size limit for(int i = B - 1; i >= 0; --i) { for(int j = 0; j < mid; ++j) { avail.insert(Y[i]); if(avail.size() == T) break; } if(avail.size() == T) break; } bool done[T]; memset(done, 0, sizeof(done)); for(int i = T - 1; i >= 0; --i) { if(avail.upper_bound(a[i].second) != avail.end()) { avail.erase(avail.upper_bound(a[i].second)); done[i] = 1; } } avail.clear(); for(int i = A - 1; i >= 0; --i) { for(int j = 0; j < mid; ++j) { avail.insert(X[i]); if(avail.size() == T) break; } if(avail.size() == T) break; } for(int i = T - 1; i >= 0; --i) { if(!done[i]) { if(avail.upper_bound(a[i].first) != avail.end()) { avail.erase(avail.upper_bound(a[i].first)); done[i] = 1; } } } bool alldone = 1; for(int i = 0; i < T; ++i) alldone &= done[i]; if(alldone) ans = mid, r = mid - 1; else l = mid + 1; // next ambil dr s terbesar yg bs diambil w nya } return ans; }

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

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:27:33: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |                 if(avail.size() == T)
      |                    ~~~~~~~~~~~~~^~~~
robots.cpp:30:29: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |             if(avail.size() == T)
      |                ~~~~~~~~~~~~~^~~~
robots.cpp:45:33: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |                 if(avail.size() == T)
      |                    ~~~~~~~~~~~~~^~~~
robots.cpp:48:29: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |             if(avail.size() == T)
      |                ~~~~~~~~~~~~~^~~~
#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...