#include "king.h"
#include<map>
#include<vector>
#include<algorithm>
#include<iostream>
#define ll long long
#define rep(i,a,b) for(int i = a;i < b;i++)
#define MAXN 300003
long long SendInfo(std::vector<int> W, std::vector<int> C) {
int n = W.size();
int cur = 0;
sort(W.rbegin(),W.rend());
sort(C.rbegin(),C.rend());
rep(i,0,n)
{
if(W[i] <= C[cur])
{
cur++;
}
}
return cur;
}
#include "vassal.h"
#include<map>
#include<vector>
#include<iostream>
#include<algorithm>
#include<set>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define MAXN 1000003
#define INF 1e17
using namespace std;
long long maxi;
ll seg[4*MAXN];
vector < vector < ll > > chairs(MAXN);
ll sz = MAXN-2;
void update(ll low,ll high,ll pos,ll slow,ll val)
{
if(low == high && low == slow)
{
seg[pos] += val;
return;
}
if(low > slow || high < slow)
return;
ll mid = (low+high)/2;
update(low,mid,pos*2+1,slow,val);
update(mid+1,high,pos*2+2,slow,val);
seg[pos] = seg[pos*2+1]+seg[pos*2+2];
return;
}
ll query(ll low,ll high,ll pos,ll slow)
{
if(seg[pos] == 0)
return MAXN;
ll mid= (low+high)/2;
if(low >= slow)
{
if(low == high)
return low;
else if(seg[pos*2+1] > 0)
return query(low,mid,pos*2+1,slow);
else
return query(mid+1,high,pos*2+2,slow);
}
if(high < slow)
return MAXN;
return min(query(low,mid,pos*2+1,slow),query(mid+1,high,pos*2+2,slow));
}
void Init(long long B, std::vector<int> C)
{
int n = C.size();
vector < int > tmp = C;
sort(tmp.rbegin(),tmp.rend());
maxi = INF;
rep(i,0,n)
{
update(0,sz,0,C[i],1);
chairs[C[i]].push_back(i);
}
return;
}
int Maid(int W){
if(W>maxi)
return -1;
else
{
ll cur = query(0,sz,0,W);
if(cur == MAXN)
return -1;
else
{
update(0,sz,0,cur,-1);
ll ch = chairs[cur][0];
chairs[cur].erase(chairs[cur].begin());
return ch;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
24508 KB |
Correct |
2 |
Correct |
23 ms |
24724 KB |
Correct |
3 |
Correct |
24 ms |
24856 KB |
Correct |
4 |
Correct |
24 ms |
24868 KB |
Correct |
5 |
Correct |
24 ms |
24848 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
131 ms |
44844 KB |
Correct |
2 |
Correct |
190 ms |
48128 KB |
Correct |
3 |
Correct |
196 ms |
48836 KB |
Correct |
4 |
Correct |
212 ms |
48972 KB |
Correct |
5 |
Correct |
219 ms |
48960 KB |
Correct |
6 |
Correct |
232 ms |
48696 KB |
Correct |
7 |
Correct |
183 ms |
48772 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
187 ms |
45104 KB |
B = 50991 |
2 |
Partially correct |
302 ms |
48388 KB |
B = 91406 |
3 |
Partially correct |
234 ms |
48832 KB |
B = 49847 |
4 |
Partially correct |
352 ms |
48968 KB |
B = 99850 |
5 |
Partially correct |
344 ms |
48964 KB |
B = 99598 |
6 |
Partially correct |
333 ms |
48968 KB |
B = 99746 |
7 |
Partially correct |
259 ms |
48840 KB |
B = 49910 |
8 |
Correct |
154 ms |
36928 KB |
Correct |