제출 #239234

#제출 시각아이디문제언어결과실행 시간메모리
239234aggu_01000101구경하기 (JOI13_watching)C++14
100 / 100
72 ms7928 KiB
#include <bits/stdc++.h> #define int long long #define INF 1000000000000000 #define lchild(i) (i*2 + 1) #define rchild(i) (i*2 + 2) #define mid(l, u) ((l+u)/2) #define x(p) p.first #define y(p) p.second #define MOD 998244353 using namespace std; int n, p, q; vector<int> v; int ct[2005][2]; int makect(int w){ for(int i = 1;i<=n;i++){ auto it = lower_bound(v.begin(), v.end(), v[i] + w); it--; int ind = it - v.begin(); ct[i][0] = ind; it = lower_bound(v.begin(), v.end(), v[i] + w + w); it--; ind = it - v.begin(); ct[i][1] = ind; } } bool f(int w){ makect(w); int dp[p+1][q+1]; dp[0][0] = 0; for(int i = 0;i<=p;i++){ for(int j = 0;j<=q;j++){ if(i==0 && j==0) continue; dp[i][j] = -INF; if(i>0){ dp[i][j] = max(dp[i][j], ct[dp[i-1][j]+1][0]); } if(j>0){ dp[i][j] = max(dp[i][j], ct[dp[i][j-1]+1][1]); } if(dp[i][j] == n) return true; } } return false; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>n>>p>>q; int a[n]; for(int i = 0;i<n;i++) cin>>a[i]; sort(a, a+n); v.push_back(-1); for(int i = 0;i<n;i++) v.push_back(a[i]); p = min(p, n); q = min(q, n); int l = 1; int u = 1e9; int ans = 1e9; while(l<=u){ int mid = mid(l, u); bool cando = f(mid); if(cando){ ans = min(ans, mid); u = mid - 1; } else l = mid + 1; } cout<<ans<<"\n"; }

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

watching.cpp: In function 'long long int makect(long long int)':
watching.cpp:25:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...