답안 #1061728

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1061728 2024-08-16T12:16:25 Z anango 팀들 (IOI15_teams) C++17
0 / 100
4000 ms 24748 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:55: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]
   55 |  if (pointer==req.size()) {
      |      ~~~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 424 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 600 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 4952 KB Output is correct
2 Correct 12 ms 5132 KB Output is correct
3 Correct 13 ms 4980 KB Output is correct
4 Correct 15 ms 6856 KB Output is correct
5 Correct 12 ms 5464 KB Output is correct
6 Correct 10 ms 5136 KB Output is correct
7 Correct 9 ms 4952 KB Output is correct
8 Correct 10 ms 4956 KB Output is correct
9 Correct 8 ms 5848 KB Output is correct
10 Incorrect 6 ms 5200 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 5764 KB Output is correct
2 Correct 58 ms 5716 KB Output is correct
3 Execution timed out 4037 ms 5712 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 206 ms 24748 KB Output is correct
2 Correct 225 ms 24584 KB Output is correct
3 Execution timed out 4070 ms 23824 KB Time limit exceeded
4 Halted 0 ms 0 KB -