제출 #423202

#제출 시각아이디문제언어결과실행 시간메모리
423202Antekb팀들 (IOI15_teams)C++14
0 / 100
2372 ms101184 KiB
#include "teams.h" #include<bits/stdc++.h> #define st first #define nd second #define pb(x) push_back(x); using namespace std; const int N=(1<<19); int n; vector<int> tab[N+N]; void init(int _N, int A[], int B[]) { n=_N; for(int i=0; i<n; i++){ //cerr<<A[i]<<" "<<B[i]<<"\n"; A[i]+=N; while(A[i]){ tab[A[i]].pb(B[i]); A[i]/=2; } } for(int i=1; i<N+N; i++)sort(tab[i].begin(), tab[i].end()); } int count(int l, int r, int y){ int ans=0; //cerr<<l<<" "<<r<<" "<<y<<" "; for(l+=N, r+=N; l<r; l>>=1, r>>=1){ if(l&1){ ans+=tab[l].end()-lower_bound(tab[l].begin(), tab[l].end(), y); l++; } if(r&1){ --r; ans+=tab[r].end()-lower_bound(tab[r].begin(), tab[r].end(), y); } } //cerr<<ans<<"\n"; return ans; } int dp[N], tab2[N]; vector<pair<int, int> > nowe; int check(int k, int l){ int L=tab2[l], R=N; while(L<R){ int M=(L+R)>>1; if(dp[k]-count(tab2[k]+1, M+1, M)>dp[l]-count(tab2[l]+1, M+1, M)){ L=M+1; } else R=M; } return L; } int can(int M, int K[]) { //cerr<<"a\n"; sort(K, K+M); for(int i=0; i<M; i++)tab2[i]=K[i]; set<int> S, S2;//S2 <0 set<pair<int, int> > todo; for(int i=0; i<M; i++){ while(todo.size() && (*todo.begin()).st<=K[i]){ int a=(*todo.begin()).nd; if(S.find(a)!=S.end()){ S.erase(S.find(a)); S2.erase(S2.find(-a)); if(S.lower_bound(a)!=S.end() && S2.lower_bound(a)!=S2.end()){ int b=*S.lower_bound(a), c=-*S2.lower_bound(a); nowe.pb(make_pair(c, check(c, b))); } } todo.erase(todo.begin()); while(nowe.size()){ todo.insert(nowe.back()); nowe.pop_back(); } } dp[i]=K[i]-count(0, K[i]+1, K[i]); //for(int j=0; j<i; j++){ if(S.size()){ int p=*S.begin(); dp[i]=max(dp[i], dp[p]+K[i]-count(K[p]+1, K[i]+1, K[i])); } //cerr<<i<<" "<<dp[i]<<"\n"; if(dp[i]>0)return 0; if(S.size()){ int b=-*S2.begin(); todo.insert({check(b, i), b}); } S.insert(i); S2.insert(-i); } return 1; }

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

teams.cpp: In function 'int count(int, int, int)':
teams.cpp:27:65: warning: conversion from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'} to 'int' may change value [-Wconversion]
   27 |    ans+=tab[l].end()-lower_bound(tab[l].begin(), tab[l].end(), y);
      |                                                                 ^
teams.cpp:32:65: warning: conversion from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'} to 'int' may change value [-Wconversion]
   32 |    ans+=tab[r].end()-lower_bound(tab[r].begin(), tab[r].end(), y);
      |                                                                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...