# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
639836 | ghostwriter | 로봇 (IOI13_robots) | C++14 | 3100 ms | 24840 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "robots.h"
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include <debug.h>
#include "grader.c"
#endif
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define _pb pop_back
#define _pf pop_front
#define lb lower_bound
#define ub upper_bound
#define mtp make_tuple
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll; typedef unsigned long long ull;
typedef double db; typedef long double ldb;
typedef pair<int, int> pi; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll;
typedef string str;
template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
#define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
#define EACH(i, x) for (auto &(i) : (x))
#define WHILE while
#define file "TEST"
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); }
/*
Tran The Bao
CTL - Da Lat
Cay ngay cay dem nhung deo duoc cong nhan
*/
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,avx2")
const int T = 1e6 + 5;
const int N = 5e4 + 5;
int a, b, t, x[N], y[N];
pi c[T];
bool cmp(pi &a, pi &b) { return a.st < b.st; }
bool check(int m) {
multiset<int> s;
int l = 1;
FOR(i, 1, a) {
WHILE(l <= t && c[l].st < x[i]) {
s.insert(c[l].nd);
++l;
}
int cnt = min(m, sz(s));
FOR(j, 1, cnt) s.erase(--s.end());
}
WHILE(l <= t) s.insert(c[l++].nd);
FOR(i, 1, b) {
int cnt = 0;
WHILE(cnt < m && !s.empty()) {
int cur = *s.begin();
if (cur >= y[i]) break;
s.erase(s.begin());
++cnt;
}
}
if (!s.empty()) return 0;
return 1;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
a = A;
b = B;
t = T;
FOR(i, 1, a) x[i] = X[i - 1];
FOR(i, 1, b) y[i] = Y[i - 1];
FOR(i, 1, t) c[i] = {W[i - 1], S[i - 1]};
sort(x + 1, x + 1 + a);
sort(y + 1, y + 1 + b);
sort(c + 1, c + 1 + t, cmp);
int l = 1, r = t, ans = -1;
WHILE(l <= r) {
int mid = l + (r - l) / 2;
if (check(mid)) {
ans = mid;
r = mid - 1;
}
else l = mid + 1;
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |