Submission #635408

#TimeUsernameProblemLanguageResultExecution timeMemory
635408FulopMateGlobal Warming (CEOI18_glo)C++17
15 / 100
72 ms3576 KiB
#include <iostream> #include <algorithm> #include <vector> using namespace std; const int maxn = 200010; int t[maxn], _end[maxn]; int dp[maxn]; int main() { int n, x; cin >> n >> x; for (int i = 1; i <= n; i++) cin >> t[i]; fill(dp, dp + n + 2, INT32_MAX); dp[0] = INT32_MIN; for (int i = 1; i <= n; i++) { int j = upper_bound(dp, dp + n + 1, t[i]) - dp; if(j <= 0 || j > n)while(1); if (dp[j - 1] < t[i] && t[i] < dp[j]) { dp[j] = t[i]; _end[i] = j; } else { _end[i] = j - 1; } } fill(dp, dp + n + 2, INT32_MIN); dp[0] = INT32_MAX; int ans = 0; for (int i = n; i > 0; i--) { int l = 0, r = n + 1; while (l + 1 < r) { int m = (l + r) / 2; if (dp[m] > t[i] - x)l = m; else r = m; } ans = max(ans, _end[i] + l); l = 0, r = n + 1; while (l + 1 < r) { int m = (l + r) / 2; if (dp[m] > t[i])l = m; else r = m; } dp[l + 1] = t[i]; } cout << ans << endl; }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:19:27: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   19 |        if(j <= 0 || j > n)while(1);
      |                           ^~~~~
glo.cpp:20:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   20 |   if (dp[j - 1] < t[i] && t[i] < dp[j]) {
      |   ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...