Submission #1344466

#TimeUsernameProblemLanguageResultExecution timeMemory
1344466madamadam3팀들 (IOI15_teams)C++20
34 / 100
4094 ms33552 KiB
#include "teams.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

using keyset = tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update>;

template<class T> bool chmin(T& a, const T&b) {return b < a ? a = b, 1 : 0;}
template<class T> bool chmax(T& a, const T&b) {return a < b ? a = b, 1 : 0;}

#define pb push_back
#define f first
#define s second
#define bg(x) (x).begin()
#define en(x) (x).end()
#define all(x) bg(x), en(x)
#define sz(x) (int((x).size()))
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rev(i, a, b) for (int i = a; i >= b; i--)

const int INF = 1e9+5;

#ifdef LOCAL
	#define dbg(x) cout << #x << " = " << x << "\n"
#else
	#define dbg(x)
#endif

int n; vi a, b, idx;

void init(int N, int A[], int B[]) {
	n = N; a.assign(A, A+N), b.assign(B, B+N);
	idx.resize(n); iota(all(idx), 0); sort(all(idx), [&](int i, int j) {return a[i] == a[j] ? b[i] < b[j] : a[i] < a[j];});
}

int m; vi k;
int can(int M, int K[]) {
	m = M; k.assign(K, K+m);
	sort(all(k)); long long x = accumulate(all(k), 0LL);
	if (x > n) return 0;

	bool ok = true;
	set<pi> avail; int pos = 0;
	for (auto v : k) {
		while (pos < n && a[idx[pos]] <= v) avail.insert({b[idx[pos]], idx[pos]}), pos++;
		int v2 = v; 
		while (!avail.empty() && v2 > 0) {
			auto t = *avail.begin(); avail.erase(t);
			if (t.first < v) continue;
			v2--;
		}

		if (v2 > 0) {ok = false; break;}
	}
	return ok;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...