Submission #242868

#TimeUsernameProblemLanguageResultExecution timeMemory
242868godwindTeams (IOI15_teams)C++14
21 / 100
4101 ms9976 KiB
#include "teams.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <set>
#include <map>
#include <queue>
#include <cstring>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <functional>

using namespace std;

const int N = 100 * 1000 + 228;

int n;
int a[N], b[N];
bool used[N];

void init(int N, int A[], int B[]) {
	n = N;
	for (int i = 0; i < n; ++i) {
		a[i] = A[i];
		b[i] = B[i];
	}
}

int can(int M, int K[]) {
	for (int i = 0; i < n; ++i) {
		used[i] = 0;
	}
	int sum_all = 0;
	for (int i = 0; i < M; ++i) {
		sum_all += K[i];
		if (sum_all > n) {
			return 0;
		}
	}
	sort(K, K + M);
	for (int xxx = 0; xxx < M; ++xxx) {
		int S = K[xxx];
		for (int it = 0; it < S; ++it) {
			int opt = -1;
			for (int i = 0; i < n; ++i) {
				if (a[i] <= S && S <= b[i] && !used[i]) {
					if (opt == -1) {
						opt = i;
					} else {
						if (b[i] < b[opt]) {
							opt = i;
						}
					}
				}
			}
			if (opt == -1) return 0;
			used[opt] = 1;
		}
	}
	return 1;
}

Compilation message (stderr)

teams.cpp: In function 'void init(int, int*, int*)':
teams.cpp:23:34: warning: declaration of 'N' shadows a global declaration [-Wshadow]
 void init(int N, int A[], int B[]) {
                                  ^
teams.cpp:17:11: note: shadowed declaration is here
 const int N = 100 * 1000 + 228;
           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...