Submission #204233

#TimeUsernameProblemLanguageResultExecution timeMemory
204233SegtreeTeams (IOI15_teams)C++14
21 / 100
126 ms24532 KiB
#include"teams.h" #include<iostream> #include<algorithm> #include<vector> #include<queue> using namespace std; typedef long long ll; typedef pair<ll,ll> P; #define chmin(a,b) a=min(a,b) #define chmax(a,b) a=max(a,b) #define rep(i,n) for(int i=0;i<n;i++) #define mod 1000000007 #define mad(a,b) a=(a+b)%mod #define NS 110 vector<P> v; int dat[NS]; void init(int N,int A[],int B[]){ rep(i,N)v.push_back(make_pair(B[i],A[i])); sort(v.begin(),v.end()); rep(i,NS)dat[i]=0; } void add(int K){ rep(i,v.size()){ if(v[i].second<=K&&dat[i]==0)dat[i]=1; } } void erase(int n){ for(int i=0;i<=n;i++){ if(dat[i]==1)dat[i]=2; } } int sum(int n){ ll res=0; for(int i=0;i<=n;i++){ res+=(dat[i]==1); } return res; } int can(int M,int K[]){ rep(i,NS)dat[i]=0; sort(K,K+M); rep(i,M){ add(K[i]); ll l,r,mid; l=-1,r=v.size(); while(l<r-1){ mid=(l+r)>>1; (v[mid].first<K[i]?l:r)=mid; } erase(l); l=-1,r=v.size(); while(l<r-1){ mid=(l+r)>>1; (sum(mid)>=K[i]?r:l)=mid; } if(r==v.size())return 0; erase(r); } return 1; } /* int main(){ int n,a[110],b[110]; cin>>n; rep(i,n)cin>>a[i]>>b[i]; init(n,a,b); while(1){ int m,k[110]; cin>>m; rep(i,m)cin>>k[i]; cout<<(can(m,k)?"YES":"NO")<<endl; } }*/

Compilation message (stderr)

teams.cpp: In function 'void add(int)':
teams.cpp:11:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define rep(i,n) for(int i=0;i<n;i++)
teams.cpp:25:6:
  rep(i,v.size()){
      ~~~~~~~~~~                
teams.cpp:25:2: note: in expansion of macro 'rep'
  rep(i,v.size()){
  ^~~
teams.cpp: In function 'int sum(int)':
teams.cpp:39:9: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
  return res;
         ^~~
teams.cpp: In function 'int can(int, int*)':
teams.cpp:53:10: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
   erase(l);
          ^
teams.cpp:57:12: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
    (sum(mid)>=K[i]?r:l)=mid;
            ^
teams.cpp:59:7: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(r==v.size())return 0;
      ~^~~~~~~~~~
teams.cpp:60:10: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
   erase(r);
          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...