Submission #553628

#TimeUsernameProblemLanguageResultExecution timeMemory
553628QwertyPi구경하기 (JOI13_watching)C++14
0 / 100
1089 ms15960 KiB
#include <bits/stdc++.h> #define N 2013 using namespace std; int dp[N][N]; int n, p, q; vector<int> a; bool ok(int w){ for(int i = 0; i <= n; i++) for(int j = 0; j <= n; j++) dp[i][j] = (1 << 30); dp[0][0] = 0; for(int j = 0; j <= n; j++){ for(int i = 1; i <= n; i++){ int w1 = upper_bound(a.begin(), a.end(), a[i - 1] - w) - a.begin(); int w2 = upper_bound(a.begin(), a.end(), a[i - 1] - w * 2) - a.begin(); if(j > 0) dp[i][j] = min(dp[i][j], dp[w2][j - 1]); dp[i][j] = min(dp[i][j], dp[w1][j] + 1); } for(int i = 1; i <= n; i++) dp[i][j + 1] = min(dp[i][j], dp[i][j + 1]); } return dp[n][q] <= p; } int main(){ cin >> n >> p >> q; for(int i = 0; i < n; i++){ int v; cin >> v; a.push_back(v); } sort(a.begin(), a.end()); int l, r; for(l = 0, r = 1e9 + 1; l != r;){ int m = (l + r) / 2; if(ok(m)){ r = m; }else{ l = m + 1; } } cout << l << endl; }

Compilation message (stderr)

watching.cpp: In function 'bool ok(int)':
watching.cpp:11:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   11 |  for(int i = 0; i <= n; i++) for(int j = 0; j <= n; j++) dp[i][j] = (1 << 30); dp[0][0] = 0;
      |  ^~~
watching.cpp:11:80: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   11 |  for(int i = 0; i <= n; i++) for(int j = 0; j <= n; j++) dp[i][j] = (1 << 30); dp[0][0] = 0;
      |                                                                                ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...