제출 #287662

#제출 시각아이디문제언어결과실행 시간메모리
287662b00n0rp팀들 (IOI15_teams)C++17
77 / 100
4069 ms101584 KiB
#include "teams.h" #include<bits/stdc++.h> using namespace std; #define pii pair<int,int> #define F first #define S second #define pb push_back const int MAXN = 500005; const int LIM = 200; int n; pii a[MAXN]; int dp[MAXN]; vector<int> seg[2*MAXN]; void init(int N, int A[], int B[]){ n = N; for(int i = 0; i < n; i ++){ a[i] = {A[i],B[i]}; } sort(a,a+n); for(int i = 0; i < n; i ++){ seg[i+n].pb(a[i].S); } for(int i = n-1; i > 0; i --){ int c1 = 0,c2 = 0; while(c1 < seg[2*i].size() or c2 < seg[2*i+1].size()){ if(c1 == seg[2*i].size()) seg[i].pb(seg[2*i+1][c2++]); else if(c2 == seg[2*i].size()) seg[i].pb(seg[2*i][c1++]); else if(seg[2*i][c1] < seg[2*i+1][c2]) seg[i].pb(seg[2*i][c1++]); else seg[i].pb(seg[2*i+1][c2++]); } } } int query(int l,int r,int val){ l += n; r += n+1; int res = 0; while(l < r){ if(l%2){ res += seg[l].end()-lower_bound(seg[l].begin(),seg[l].end(),val); l++; } if(r%2){ --r; res += seg[r].end()-lower_bound(seg[r].begin(),seg[r].end(),val); } l /= 2; r /= 2; } return res; } int can(int M, int K[]) { sort(K,K+M); if(M > LIM){ priority_queue<int,vector<int>,greater<int> > pq; int cur = 0; for(int i = 0; i < M; i ++){ while(cur < n and a[cur].F <= K[i]){ pq.push(a[cur].S); cur++; } int cnt = 0; while(cnt < K[i] and (!pq.empty())){ int x = pq.top(); pq.pop(); if(x >= K[i]) cnt++; } if(cnt < K[i]) return 0; } return 1; } else{ dp[0] = 0; for(int i = 1; i <= M; i ++){ dp[i] = n+1; for(int j = 0; j < i; j ++){ int ind1 = (j?(lower_bound(a,a+n,make_pair(K[j-1]+1,-1))-a):0); int ind2 = (lower_bound(a,a+n,make_pair(K[i-1]+1,-1))-a)-1; dp[i] = min(dp[i],dp[j]-K[i-1]+query(ind1,ind2,K[i-1])); } if(dp[i] < 0) return 0; } return 1; } }

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

teams.cpp: In function 'void init(int, int*, int*)':
teams.cpp:30:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   while(c1 < seg[2*i].size() or c2 < seg[2*i+1].size()){
      |         ~~~^~~~~~~~~~~~~~~~~
teams.cpp:30:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   while(c1 < seg[2*i].size() or c2 < seg[2*i+1].size()){
      |                                 ~~~^~~~~~~~~~~~~~~~~~~
teams.cpp:31:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |    if(c1 == seg[2*i].size()) seg[i].pb(seg[2*i+1][c2++]);
      |       ~~~^~~~~~~~~~~~~~~~~~
teams.cpp:32:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |    else if(c2 == seg[2*i].size()) seg[i].pb(seg[2*i][c1++]);
      |            ~~~^~~~~~~~~~~~~~~~~~
teams.cpp: In function 'int query(int, int, int)':
teams.cpp:45:67: warning: conversion from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'} to 'int' may change value [-Wconversion]
   45 |    res += seg[l].end()-lower_bound(seg[l].begin(),seg[l].end(),val);
      |                                                                   ^
teams.cpp:50:67: warning: conversion from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'} to 'int' may change value [-Wconversion]
   50 |    res += seg[r].end()-lower_bound(seg[r].begin(),seg[r].end(),val);
      |                                                                   ^
teams.cpp: In function 'int can(int, int*)':
teams.cpp:83:18: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   83 |     int ind1 = (j?(lower_bound(a,a+n,make_pair(K[j-1]+1,-1))-a):0);
      |                ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
teams.cpp:84:61: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   84 |     int ind2 = (lower_bound(a,a+n,make_pair(K[i-1]+1,-1))-a)-1;
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...