제출 #939818

#제출 시각아이디문제언어결과실행 시간메모리
939818SuPythony로봇 (IOI13_robots)C++17
76 / 100
3093 ms10464 KiB
#include <bits/stdc++.h> #include "robots.h" using namespace std; typedef long long ll; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { vector<pair<int,int>> toys; for (int i=0; i<T; i++) { toys.push_back({W[i],S[i]}); } sort(X,X+A); sort(Y,Y+B); sort(toys.begin(),toys.end()); int ans=0; vector<int> done(T, 0); bool pos=true; while (true) { int no_done=0; bool is_all=true; for (int j=0; j<A; j++) { int x=X[j]; int tind=-1; int ts=-1; for (int i=0; i<T; i++) { if (done[i]) continue; is_all=false; if (W[i]<x) { if (S[i]>ts||(S[i]==ts&&W[i]>=W[tind])) { ts=S[i]; tind=i; } } } if (tind!=-1) { no_done++; done[tind]=1; } } for (int j=0; j<B; j++) { int y=Y[j]; int tind=-1; int tw=-1; for (int i=0; i<T; i++) { if (done[i]) continue; is_all=false; if (S[i]<y) { if (W[i]>=tw||(W[i]==tw&&S[i]>=S[tind])) { tw=W[i]; tind=i; } } } if (tind!=-1) { no_done++; done[tind]=1; } } ans++; if (no_done==0&&!is_all) { pos=false; break; } else if (no_done==0&&is_all) { ans--; break; } } if (pos) return ans; 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...