Submission #1061641

# Submission time Handle Problem Language Result Execution time Memory
1061641 2024-08-16T11:22:44 Z anango Teams (IOI15_teams) C++17
0 / 100
4000 ms 28236 KB
#include "teams.h"
#include <bits/stdc++.h>
#define int long long
using namespace std;

int n;
vector<pair<int,int>> students;
vector<int> ar;
vector<int> br;
void init(signed N, signed A[], signed B[]) {
	n=N; ar=br=vector<int>(n);
	students=vector<pair<int,int>>(n);
	for (int i=0; i<n; i++) {
		ar[i] = A[i]; br[i] = B[i];
		students[i] = {A[i],B[i]};
	}
	sort(students.begin(), students.end(), [&](const pair<int,int> &p1, const pair<int,int> &p2) {
		return p1.second<p2.second;
	});
}

signed can(signed M, signed K[]) {
	int m = M;
	vector<int> kvals;
	for (int i=0; i<m; i++) {
		kvals.push_back(K[i]);
	}
	sort(kvals.begin(), kvals.end());
	map<int,int> need;
	for (auto i:kvals) {
		need[i]+=i;
	}
	vector<vector<int>> req;
	for (auto i:need) {
		req.push_back({i.first,i.second});
	}
	sort(req.begin(), req.end());
	int pointer = 0;
	signed work = 0;
	for (auto student:students) {
		if (pointer==req.size()) {
			work=1;
			break;
		}
		if (student.first>req[pointer][0]) continue;
		if (student.second<req[pointer][0]) continue;
		//cout << "prereduced " << pointer <<" " << req[pointer][0] <<" " << req[pointer][1] << endl;
		req[pointer][1]--;
		//cout << "reduced " << pointer <<" " << req[pointer][0] <<" " << req[pointer][1] << endl;
		if (req[pointer][1]==0) {
			pointer++;
		}
	}
	if (pointer==req.size()) {
		work=1;
	}
	return work;
}

Compilation message

teams.cpp: In function 'int can(int, int*)':
teams.cpp:41:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |   if (pointer==req.size()) {
      |       ~~~~~~~^~~~~~~~~~~~
teams.cpp:54:13: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |  if (pointer==req.size()) {
      |      ~~~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 432 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 436 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Incorrect 1 ms 344 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 5468 KB Output is correct
2 Correct 14 ms 5580 KB Output is correct
3 Correct 13 ms 5384 KB Output is correct
4 Correct 15 ms 7124 KB Output is correct
5 Correct 9 ms 4964 KB Output is correct
6 Correct 9 ms 5200 KB Output is correct
7 Correct 9 ms 5040 KB Output is correct
8 Correct 9 ms 4952 KB Output is correct
9 Correct 7 ms 5928 KB Output is correct
10 Incorrect 9 ms 5212 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 51 ms 6088 KB Output is correct
2 Correct 62 ms 6200 KB Output is correct
3 Execution timed out 4088 ms 6296 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 229 ms 28120 KB Output is correct
2 Correct 219 ms 28236 KB Output is correct
3 Execution timed out 4042 ms 27012 KB Time limit exceeded
4 Halted 0 ms 0 KB -