제출 #55274

#제출 시각아이디문제언어결과실행 시간메모리
55274kingpig9로봇 (IOI13_robots)C++11
76 / 100
3041 ms35612 KiB
#include <bits/stdc++.h> #include "robots.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1 << 20; #define debug(...) fprintf(stderr, __VA_ARGS__) #define fi first #define se second #define all(v) (v).begin(), (v).end() #define fillchar(a, s) memset((a), (s), sizeof(a)) void compress (vector<int> &v) { sort(all(v)); v.resize(unique(all(v)) - v.begin()); } int A, B, N; int *X, *Y, *W, *S; int ordw[MAXN], ords[MAXN]; struct cmpw { bool operator() (int x, int y) { return pii(W[x], S[x]) < pii(W[y], S[y]); } }; struct cmps { bool operator() (int x, int y) { return pii(S[x], W[x]) < pii(S[y], W[y]); } }; bitset<MAXN> vis; bool moo (int g) { if (g * ll(A + B) < N) { return false; } priority_queue<int, vector<int>, cmps> pqs; priority_queue<int, vector<int>, cmpw> pqw; //what is the limit here? int rem = N; vis.reset(); //memory limit is so fucking strict...i don't even understand int ptr = 0; for (int i = 0; i < A; i++) { //insert stuff in for (; ptr < N && W[ordw[ptr]] < X[i]; ptr++) { pqs.push(ordw[ptr]); } for (int taken = 0; !pqs.empty() && taken < g; taken++) { vis[pqs.top()] = true; rem--; pqs.pop(); } } ptr = 0; for (int i = 0; i < B; i++) { for (; ptr < N && S[ords[ptr]] < Y[i]; ptr++) { int ind = ords[ptr]; if (!vis[ind]) { pqw.push(ind); } } for (int taken = 0; !pqw.empty() && taken < g; taken++) { vis[pqw.top()] = true; rem--; pqw.pop(); } } return rem == 0; } int putaway (int aaa, int bbb, int nnn, int xxx[], int yyy[], int www[], int sss[]) { A = aaa; B = bbb; N = nnn; X = xxx; Y = yyy; W = www; S = sss; sort(X, X + A); sort(Y, Y + B); for (int i = 0; i < N; i++) { if (W[i] >= X[A - 1] && S[i] >= Y[B - 1]) { return -1; } ordw[i] = i; ords[i] = i; } sort(ordw, ordw + N, cmpw()); sort(ords, ords + N, cmps()); //memory is the issue here int lo = 0, hi = N; while (hi - lo > 1) { int mid = (lo + hi) / 2; if (moo(mid)) { hi = mid; } else { lo = mid; } } return hi; }
#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...