Submission #1091979

#TimeUsernameProblemLanguageResultExecution timeMemory
1091979thangdz2k7Sparklers (JOI17_sparklers)C++17
0 / 100
0 ms348 KiB
// author : thembululquaUwU // 3.9.2024 #include <bits/stdc++.h> #define pb push_back #define fi first #define se second #define endl '\n' using namespace std; using ll = long long; using ii = pair <int, int>; using vi = vector <int>; const int N = 1e3 + 5; const int mod = 1e9 + 7; void maxl(auto &a, auto b) {a = max(a, b);} void minl(auto &a, auto b) {a = min(a, b);} int n, k, t, x[N], dp[N][N]; int ask(int l, int r, int v){ if (dp[l][r] > -1) return dp[l][r]; if (l >= r) return 0; if ((x[r] - x[l]) / (v * 2) <= 1ll * t * (r - l) && (ask(l + 1, r, v) | ask(l, r - 1, v))) dp[l][r] = 1; else dp[l][r] = 0; return dp[l][r]; } void solve(){ cin >> n >> k >> t; for (int i = 1; i <= n; ++ i) cin >> x[i]; int lo = 1, hi = x[n] / t + 1, ans = hi; while (lo <= hi){ int mid = lo + hi >> 1; for (int i = 1; i <= n; ++ i) for (int j = 1; j <= n; ++ j) dp[i][j] = -1; dp[k][k] = 1; if (ask(1, n, mid)) ans = mid, hi = mid - 1; else lo = mid + 1; } cout << ans; } int main(){ if (fopen("pqh.inp", "r")){ freopen("pqh.inp", "r", stdin); freopen("pqh.out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; // cin >> t; while (t --) solve(); return 0; }

Compilation message (stderr)

sparklers.cpp:18:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   18 | void maxl(auto &a, auto b) {a = max(a, b);}
      |           ^~~~
sparklers.cpp:18:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   18 | void maxl(auto &a, auto b) {a = max(a, b);}
      |                    ^~~~
sparklers.cpp:19:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void minl(auto &a, auto b) {a = min(a, b);}
      |           ^~~~
sparklers.cpp:19:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void minl(auto &a, auto b) {a = min(a, b);}
      |                    ^~~~
sparklers.cpp: In function 'int ask(int, int, int)':
sparklers.cpp:27:5: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
   27 |     else dp[l][r] = 0; return dp[l][r];
      |     ^~~~
sparklers.cpp:27:24: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
   27 |     else dp[l][r] = 0; return dp[l][r];
      |                        ^~~~~~
sparklers.cpp: In function 'void solve()':
sparklers.cpp:35:22: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   35 |         int mid = lo + hi >> 1;
      |                   ~~~^~~~
sparklers.cpp: In function 'int main()':
sparklers.cpp:46:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |         freopen("pqh.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
sparklers.cpp:47:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |         freopen("pqh.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...