Submission #540862

#TimeUsernameProblemLanguageResultExecution timeMemory
540862GioChkhaidzeTeams (IOI15_teams)C++14
0 / 100
4081 ms57200 KiB
#include <bits/stdc++.h> #include "teams.h" #define ll long long #define pb push_back using namespace std; const int Nn = 5e5 + 5; ll n, a[Nn], b[Nn], f[Nn]; vector < ll > G[Nn]; multiset < ll > st; 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]; } for (int i = 0; i < n; ++i) { G[a[i]].pb(i); } } int can(int M, int K[]) { ll s = 0; for (int i = 0; i < M; ++i) { f[K[i]]++; s += K[i]; } st.clear(); bool ok = true; if (s > n) ok = false; else { for (int i = 1; i <= n; ++i) { for (int j = 0; j < G[i].size(); ++j) { int id = G[i][j]; st.insert(b[id]); } if (f[i] * i > n) { ok = false; break; } for (int j = 1; j <= f[i] * i; ++j) { if (!st.size()) { ok = false; break; } if ((*st.begin()) < i) { ok = false; break; } st.erase(st.find(*st.begin())); } if(!ok) break; } } for (int i = 0; i < M; ++i) { f[K[i]] = 0; } return ok; }

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:36:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |    for (int j = 0; j < G[i].size(); ++j) {
      |                    ~~^~~~~~~~~~~~~
teams.cpp:37:20: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
   37 |     int id = G[i][j];
      |                    ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...