제출 #92674

#제출 시각아이디문제언어결과실행 시간메모리
92674LittleFlowers__구경하기 (JOI13_watching)C++14
50 / 100
1044 ms32068 KiB
#include <bits/stdc++.h> #define int long long #define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a) #define reset(f, x) memset(f, x, sizeof(f)) using namespace std; const int N=2010; int n,p,q; int a[N]; int f[N][N]; bool C(int x) { reset(f,-1); f[0][p]=q; forinc(i,0,n-1) forinc(j,0,p) if(f[i][j]>-1) { if(j) { int t=upper_bound(a+1,a+n+1,a[i+1]+x-1)-a-1; f[t][j-1]=max(f[t][j-1],f[i][j]); } if(f[i][j]) { int t=upper_bound(a+1,a+n+1,a[i+1]+x*2-1)-a-1; f[t][j]=max(f[t][j],f[i][j]-1); } } forinc(i,0,p) if(f[n][i]>-1) return 1; return 0; } main() { //freopen("WATCHING.inp","r",stdin); cin>>n>>p>>q;p=min(p,n),q=min(q,n); for(int i=1; i<=n; ++i) cin>>a[i]; sort(a+1,a+n+1); int l=1,m,r=1e9,ans; while(l<=r) { m=l+(r-l)/2; if(C(m)) ans=m,r=m-1; else l=m+1; } cout<<ans; }

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

watching.cpp:30:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...