Submission #1057715

#TimeUsernameProblemLanguageResultExecution timeMemory
1057715MuhammadSaramTeams (IOI15_teams)C++17
0 / 100
2086 ms104076 KiB
#include <bits/stdc++.h> #include "teams.h" using namespace std; const int M = 5e5 + 1; #define all(v) v.begin(), v.end() int n,pre[M]; vector<int> V,seg[M*2]; void make(int v=0,int s=0,int e=n) { for (int i=s;i<e;i++) seg[v].push_back(V[i]); sort(all(seg[v])); if (s+1==e) return; int mid=(s+e)/2,lc=v+1,rc=v+(mid-s)*2; make(lc,s,mid); make(rc,mid,e); } int get(int l,int r,int x,int v=0,int s=0,int e=n) { if (l>=e or r<=s) return 0; if (l<=s && e<=r) { int y=upper_bound(all(seg[v]),x)-begin(seg[v]); return y; } int mid=(s+e)/2,lc=v+1,rc=v+(mid-s)*2; return get(l,r,x,lc,s,mid)+get(l,r,x,rc,mid,e); } void init(int N,int A[],int B[]) { n=N; vector<pair<int,int>> v1; for (int i=0;i<n;i++) v1.push_back({B[i],A[i]}),pre[B[i]]++; sort(v1.begin(),v1.end()); for (auto i:v1) V.push_back(i.second); for (int i=1;i<M;i++) pre[i]+=pre[i-1]; make(); } int can(int m,int k[]) { sort(k,k+m); reverse(k,k+m); int val=n; for (int i=0;i<m;i++) { int s=pre[k[i]-1]-1,e=val; while (s+1<e) { int mid=(s+e)/2; if (get(mid,val,k[i])>=k[i]) s=mid; else e=mid; } if (s==pre[k[i]-1]-1) return 0; val=s; } return 1; }

Compilation message (stderr)

teams.cpp: In function 'int get(int, int, int, int, int, int)':
teams.cpp:31:35: warning: conversion from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'} to 'int' may change value [-Wconversion]
   31 |   int y=upper_bound(all(seg[v]),x)-begin(seg[v]);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...