제출 #727742

#제출 시각아이디문제언어결과실행 시간메모리
727742sandry24구경하기 (JOI13_watching)C++17
0 / 100
2 ms468 KiB
#include <bits/stdc++.h> using namespace std; //#pragma GCC optimize("O3,unroll-loops") //#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pi; #define pb push_back #define mp make_pair #define f first #define s second const int maxn = 2005; vector<ll> events; int n, small, large; bool possible(ll w){ vector<ll> small_range(n+1), large_range(n+1); int j = 0; for(int i = 0; i < n; i++){ while(j < n && events[j] - events[i] < w) j++; small_range[i+1] = j; j--; } j = 0; for(int i = 0; i < n; i++){ while(j < n && events[j] - events[i] < 2*w) j++; large_range[i+1] = j; j--; } vector<vector<ll>> dp(small+1, vector<ll>(large+1)); //dp[i][j] = highest index you can cover with i small j big for(int i = 0; i <= small; i++){ for(int j = 0; j <= large; j++){ if(i > 0) dp[i][j] = max(dp[i][j], small_range[dp[i-1][j] + 1]); if(j > 0) dp[i][j] = max(dp[i][j], large_range[dp[i][j-1] + 1]); } } return (dp[small][large] >= n); } void solve(){ cin >> n >> small >> large; if(small + large >= n){ cout << 1 << '\n'; return; } events = vector<ll>(n); for(int i = 0; i < n; i++){ cin >> events[i]; } sort(events.begin(), events.end()); ll current = 0; for(ll add = 1e9; add > 0; add /= 2){ //cerr << current << '\n'; while(!possible(current+add)) current += add; } cout << current+1 << '\n'; } int main(){ //freopen("input.txt", "r", stdin); //freopen("test.out", "w", stdout); //ios::sync_with_stdio(0); cin.tie(0); int t = 1; //cin >> t; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...