Submission #888960

#TimeUsernameProblemLanguageResultExecution timeMemory
888960dwuyWatching (JOI13_watching)C++14
0 / 100
66 ms31912 KiB
/// dwuy: _,\,,,_\,__,\,,_ #include <bits/stdc++.h> #define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL) #define file(a) freopen(a".inp","r",stdin); freopen(a".out", "w",stdout) #define fi first #define se second #define endl "\n" #define len(s) int32_t(s.length()) #define MASK(k)(1LL<<(k)) #define TASK "" #define int long long using namespace std; typedef tuple<int, int, int> tpiii; typedef pair<double, double> pdd; typedef pair<int, int> pii; typedef long long ll; const long long OO = 1e18; const int MOD = 1e9 + 7; const int INF = 1e9; const int MX = 2005; int n, p, q; int a[MX]; int dp[MX][MX]; /// dp[i][j] : least large camera to check a[1, i], used j small camera; void nhap(){ cin >> n >> p >> q; for(int i=1; i<=n; i++) cin >> a[i]; if(p+q>=n){ cout << 0; exit(0); } } bool ok(int mid){ memset(dp, 0x3f, sizeof dp); memset(dp[0], 0, sizeof dp[0]); for(int i=1, sm=1, bg=1; i<=n; i++){ while(a[i] - a[sm] + 1 > mid) sm++; while(a[i] - a[bg] + 1 > mid+mid) bg++; for(int j=1; j<=p; j++){ dp[i][j] = min({dp[i][j], dp[sm-1][j-1], dp[bg-1][j] + 1}); } } return dp[n][p] <= q; } void solve(){ int res = 0; for(int lo=1, hi=1000000000; lo<=hi;){ int mid = (lo+hi)>>1; if(ok(mid)) res = mid, hi = mid - 1; else lo = mid + 1; } cout << res; } int32_t main(){ fastIO; //file(TASK); nhap(); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...