This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
* user: ppavic
* fname: Patrik
* lname: Pavić
* task: robots
* score: 14.0
* date: 2019-07-03 13:44:35.598305
*/
#include "robots.h"
#include <cstdio>
#include <cstring>
#include <ctime>
#include <vector>
#include <algorithm>
#define X first
#define Y second
#define PB push_back
using namespace std;
typedef pair < int, int > pii;
typedef vector < int > vi;
typedef vector < pii > vp;
typedef long long ll;
const int N = 1e6 + 500;
const int INF = 0x3f3f3f3f;
vi r,s;
int pref[N];
int A, B, T;
bool check(int K){
for(int i = 0;i <= A;i++){
if((ll)K * (A - i) < (ll)pref[i])
return 0;
}
return 1;
}
int putaway(int AA, int BB, int TT, int X[], int Y[], int W[], int S[]) {
A = AA; B = BB; T = TT;
for(int i = 0;i < A;i++) r.PB(X[i]);
sort(r.begin(), r.end());
for(int i = 0;i < T;i++){
W[i] = upper_bound(r.begin(), r.end(), W[i]) - r.begin();
pref[W[i]]++;
}
for(int i = A;i >= 0;i--){
pref[i] += pref[i + 1];
}
int ans = 0;
for(int i = 25;i >= 0;i--)
if(!check(ans + (1 << i))) ans += (1 << i);
if(ans + 1 == (1 << 26)) return -1;
return ans + 1;
}
# | 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... |