제출 #203979

#제출 시각아이디문제언어결과실행 시간메모리
203979SegtreeGap (APIO16_gap)C++14
0 / 100
83 ms3308 KiB
#include<iostream> #include<algorithm> #include<vector> #include"gap.h" using namespace std; typedef long long ll; #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 /* ll a[100010],n,m; void MinMax(ll s,ll t,ll &mn,ll &mx){ m++; ll l,r,mid; l=-1,r=n; while(l<r-1){ mid=(l+r)>>1; if(a[mid]>=s)r=mid; else l=mid; } mn=a[r]; l=-1,r=n; while(l<r-1){ mid=(l+r)>>1; if(a[mid]<=t)l=mid; else r=mid; } mx=a[l]; }*/ ll findGap(int T,int N){ ll mn,mx; ll a,b; MinMax(0,1e18,&a,&b); ll lower=(b-a+N-1-1)/N-1; vector<ll> v; v.push_back(a); v.push_back(b); for(int i=0;i<N;i++){ MinMax(a+i*lower+1,a+(i+1)*lower,&mn,&mx); if(mn>=0)v.push_back(mn); if(mx>=0)v.push_back(mx); } sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end()); ll ans=0; rep(i,v.size()-1)ans=max(ans,v[i+1]-v[i]); return ans; } /* int main(){ n=100000; rep(i,n)a[i]=rand()%mod; sort(a,a+n); ll ans=0; rep(i,n-1)chmax(ans,a[i+1]-a[i]); m=0; cout<<ans<<endl; cout<<findGap(0,n)<<endl; cout<<"m="<<m<<endl; }*/

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

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:9:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define rep(i,n) for(int i=0;i<n;i++)
gap.cpp:49:6:
  rep(i,v.size()-1)ans=max(ans,v[i+1]-v[i]);
      ~~~~~~~~~~~~              
gap.cpp:49:2: note: in expansion of macro 'rep'
  rep(i,v.size()-1)ans=max(ans,v[i+1]-v[i]);
  ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...