Submission #43469

#TimeUsernameProblemLanguageResultExecution timeMemory
43469PowerOfNinjaGoTeams (IOI15_teams)C++14
0 / 100
40 ms19376 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(n-pos< here) return 0; bag.erase(bag.begin()+pos, bag.begin()+pos+here-1); } return 1; }

Compilation message (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...