Submission #71467

#TimeUsernameProblemLanguageResultExecution timeMemory
71467claudyWatching (JOI13_watching)C++14
100 / 100
489 ms32280 KiB
# pragma GCC optimize("O3") # include <bits/stdc++.h> std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}}; # define ll long long # define clock (clock() * 1000.0 / CLOCKS_PER_SEC) # define rc(s) return cout << s,0 # define rcg(s) cout << s;exit(0) # define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0); # define db(x) cerr << #x << " = " << x << '\n' # define pb push_back # define mp make_pair # define all(s) s.begin(),s.end() # define sz(x) (int)((x).size()) # define int ll using namespace std; int dp[2005][2005]; int n,p,q; int a[2005]; const int mx = 1e18; int check(int w) { for(int i = 0;i <= n;i++) { for(int j = 0;j <= p;j++) { dp[i][j] = 1e18; } } for(int j = 0;j <= p;j++) dp[0][j] = 0; for(int i = 1;i <= n;i++) { int x = lower_bound(a + 1,a + 1 + n,a[i] - w + 1) - a; int y = lower_bound(a + 1,a + 1 + n,a[i] - 2*w + 1) - a; for(int j = p;j >= 0;j--) { dp[i][j] = min((j > 0 ? dp[x - 1][j - 1] : mx),dp[y - 1][j] + 1); } } return (dp[n][p] <= q); } int32_t main(){_ //freopen("input","r",stdin); cin >> n >> p >> q; p = min(p,n); for(int i = 1;i <= n;i++) cin >> a[i]; int l = 1; int r = 1e9; sort(a + 1,a + 1 + n); while(l < r) { int mid = l + r >> 1; if(check(mid)) r = mid; else l = mid + 1; } rc(l); }

Compilation message (stderr)

watching.cpp: In function 'int32_t main()':
watching.cpp:55:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         int mid = l + r >> 1;
                   ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...