Submission #314068

#TimeUsernameProblemLanguageResultExecution timeMemory
314068tushar_2658Global Warming (CEOI18_glo)C++14
0 / 100
70 ms5368 KiB
#include "bits/stdc++.h" using namespace std; const int maxn = 200005; int a[maxn], x; int n; int main(int argc, char const *argv[]) { scanf("%d %d", &n, &x); for(int i = 1; i <= n; ++i){ scanf("%d", &a[i]); } vector<int> dp(n + 1, 1e8); dp[0] = -1e8; vector<int> L(n + 1); for(int i = 1; i <= n; ++i){ int idx = lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin(); dp[idx] = a[i]; L[i] = idx; } vector<int> dp1(n + 1, 1e8); dp1[0] = -1e8; int ans = 0; for(int i = 1; i <= n; ++i){ int idx = lower_bound(dp1.begin(), dp1.end(), -a[i]) - dp1.begin(); int idx1 = lower_bound(dp1.begin(), dp1.end(), -a[i] + x) - dp1.begin(); dp1[idx] = -a[i]; ans = max(ans, L[n - i + 1] + idx1 - 1); } cout << ans << endl; return 0; }

Compilation message (stderr)

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