Submission #259883

#TimeUsernameProblemLanguageResultExecution timeMemory
259883peuchGlobal Warming (CEOI18_glo)C++17
100 / 100
83 ms4676 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 10; const int INF = 2e9 + 7; int n, x; int v[MAXN]; int dp[MAXN]; int maxi[MAXN]; int ans; int main(){ scanf("%d %d", &n, &x); for(int i = 1; i <= n; i++) scanf("%d", &v[i]); for(int j = 1; j <= n; j++) dp[j] = INF; for(int i = 1; i <= n; i++){ int k = lower_bound(dp, dp + 1 + n, v[i]) - dp; dp[k] = v[i]; maxi[i] = k; ans = max(ans, k); } for(int j = 1; j <= n; j++) dp[j] = INF; dp[0] = -INF; for(int i = n; i > 0; i--){ int aux = lower_bound(dp, dp + 1 + n, -v[i]) - dp; aux--; int k = lower_bound(dp, dp + 1 + n, -v[i] - x) - dp; dp[k] = -v[i] - x; ans = max(ans, maxi[i] + aux); ans = max(ans, k); } printf("%d\n", ans); }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &x);
  ~~~~~^~~~~~~~~~~~~~~~~
glo.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &v[i]);
  ~~~~~^~~~~~~~~~~~~
#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...