Submission #149989

# Submission time Handle Problem Language Result Execution time Memory
149989 2019-09-01T07:30:32 Z (παρα)γεμιστά(#3619, cfalas, ctziapo, Charis02) King of Chairs (FXCUP4_chairs) C++17
55 / 100
212 ms 28608 KB
#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 W[n-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;
set < pi > available;
ll seg[4*MAXN];

void update(ll low,ll high,ll pos,ll slow)
{
    if(low == high && low == slow)
    {
        seg[pos]++;
        return;
    }
    if(low > slow || high < slow)
        return;

    ll mid = (low+high)/2;

    update(low,mid,pos*2+1,slow);
    update(mid+1,high,pos*2+2,slow);

    seg[pos] = seg[pos*2+1]+seg[pos*2+2];
    return;
}

ll query(ll low,ll high,ll pos,ll slow)
{
    ll mid= (low+high)/2;
    if(low >= slow)
    {
        if(seg[pos] == 0)
            return -1;
        else 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 -1;

    return max(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();
	sort(C.begin(),C.end());
    maxi = B;

	rep(i,0,n)
	{
        available.insert(mp(C[i],i));
        update(0,MAXN-1,0,C[i]);
	}

	return;
}

int Maid(int W){
    if(W>maxi)
        return -1;
    else
    {
        set < pi >::iterator it = available.lower_bound(mp(W,0));
        available.erase(it);
        return (*it).second;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1172 KB Correct
2 Correct 10 ms 1292 KB Correct
3 Correct 11 ms 1428 KB Correct
4 Correct 11 ms 1428 KB Correct
5 Correct 10 ms 1432 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 95 ms 23128 KB Correct
2 Correct 155 ms 27440 KB Correct
3 Correct 161 ms 28228 KB Correct
4 Correct 172 ms 28232 KB Correct
5 Correct 160 ms 28344 KB Correct
6 Correct 150 ms 28448 KB Correct
7 Correct 155 ms 28356 KB Correct
# Verdict Execution time Memory Grader output
1 Partially correct 107 ms 23140 KB B = 993847
2 Partially correct 187 ms 27528 KB B = 996200
3 Partially correct 197 ms 28356 KB B = 706116
4 Runtime error 212 ms 28608 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -