제출 #43470

#제출 시각아이디문제언어결과실행 시간메모리
43470PowerOfNinjaGo팀들 (IOI15_teams)C++14
21 / 100
4083 ms21036 KiB
//Power Of Ninja Go
#include <bits/stdc++.h>
#ifdef atom
#include "grader.cpp"
#else
#include "teams.h"
#endif
using namespace std;
typedef long long ll; typedef pair<int, int> ii;
#define X first
#define Y second
#define vi vector<int>
#define vii vector< ii >
#define pb push_back
const int maxn = 1e5+5;
int n;
int a[maxn], b[maxn];
void init(int N, int A[], int B[])
{
	n = N;
	for(int i = 1; i<= N; i++) a[i] = A[i-1], b[i] = B[i-1];
}
int can(int M, int K[])
{
	int sum = 0;
	for(int i = 0; i< M; i++) sum += K[i];
	if(sum> n) return 0;
	vii vec;
	for(int i = 1; i<= n; i++) vec.pb(ii(a[i], b[i]));
	sort(vec.begin(), vec.end());
	sort(K, K+M);
	vi bag;
	int ptr = 0;
	for(int i = 0; i< M; i++)
	{
		int here = K[i];
		while(ptr< n && vec[ptr].X<= here) bag.pb(vec[ptr++].Y);
		sort(bag.begin(), bag.end());
		//printf("quest %d\n", i);
		//for(auto v : bag) printf("%d ", v);
		//printf("\n");
		int pos = lower_bound(bag.begin(), bag.end(), here)-bag.begin();
		if(((int)bag.size())-pos< here) return 0;
		bag.erase(bag.begin()+pos, bag.begin()+pos+here);
	}
	return 1;
}

컴파일 시 표준 에러 (stderr) 메시지

teams.cpp: In function 'int can(int, int*)':
teams.cpp:42:65: warning: conversion to 'int' from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type {aka long int}' may alter its value [-Wconversion]
   int pos = lower_bound(bag.begin(), bag.end(), here)-bag.begin();
                                                                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...