Submission #741237

#TimeUsernameProblemLanguageResultExecution timeMemory
741237blackslexGlobal Warming (CEOI18_glo)C++17
100 / 100
63 ms7696 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; const int N = 2e5 + 5; ll n, k, a[N], b[N], ans; vector<ll> v, u; int main() { scanf("%lld %lld", &n, &k); for (int i = 1; i <= n; i++) scanf("%lld", &a[i]); for (int i = 1; i <= n; i++) { auto lower = lower_bound(v.begin(), v.end(), a[i]); if (lower == v.end()) v.emplace_back(a[i]), b[i] = v.size(); else *lower = a[i], b[i] = lower - v.begin() + 1; } for (int i = n; i >= 1; i--) { ll idx = lower_bound(u.begin(), u.end(), -a[i] + k) - u.begin(); ans = max(ans, b[i] + idx); auto lower = lower_bound(u.begin(), u.end(), -a[i]); if (lower == u.end()) u.emplace_back(-a[i]); else *lower = -a[i]; } printf("%lld", ans); }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%lld %lld", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~
glo.cpp:12:39: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     for (int i = 1; i <= n; i++) scanf("%lld", &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...