Submission #998024

#TimeUsernameProblemLanguageResultExecution timeMemory
998024lovrotSparklers (JOI17_sparklers)C++17
0 / 100
1 ms348 KiB
#include <cstdio> #include <algorithm> #include <cstring> using namespace std; typedef long long ll; const int N = 1e5 + 10; const int OO = 1e9 + 10; int n, t, k, A[N]; ll B[N]; bool solve(int l, int r, int lo, int hi) { // lo <= l | r <= hi int l_ = l, r_ = r; for(; lo >= 0 && B[lo] >= B[r]; --lo) { if(B[lo] > B[l_]) { l_ = lo; } } for(; hi < n && B[hi] <= B[l]; ++hi) { if(B[hi] < B[r_]) { r_ = hi; } } if(lo < 0 && hi >= n) { return 1; } if(l == l_ && r == r_) { return 0; } return solve(l_, r_, lo, hi); } int main() { scanf("%d%d%d", &n, &k, &t); for(int i = 0; i < n; ++i) { scanf("%d", A + i); } int lo = -1, hi = OO / t + 1; for(int mi = (lo + hi) / 2; hi - lo > 1; mi = (lo + hi) / 2) { for(int i = 0; i < n; ++i) { B[i] = A[i] - (ll) 2 * mi * t * i; } if(solve(k - 1, k - 1, k - 1, k - 1)) { hi = mi; } else { lo = mi; } } printf("%d\n", hi); return 0; }

Compilation message (stderr)

sparklers.cpp: In function 'int main()':
sparklers.cpp:37:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |  scanf("%d%d%d", &n, &k, &t);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
sparklers.cpp:38:36: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |  for(int i = 0; i < n; ++i) { scanf("%d", A + i); }
      |                               ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...