Submission #973891

#TimeUsernameProblemLanguageResultExecution timeMemory
973891vjudge1Global Warming (CEOI18_glo)C++17
100 / 100
50 ms3864 KiB
#include<bits/stdc++.h> using namespace std; int n, d; int main() { scanf("%d %d", &n, &d); vector<int> t(n), pref(n), c; for (auto &e: t) scanf("%d", &e); for (int i = 0; i < n; i++) { auto lower = lower_bound(c.begin(), c.end(), t[i]); if (lower == c.end()) c.emplace_back(t[i]), pref[i] = c.size(); else *lower = t[i], pref[i] = lower - c.begin() + 1; } int ans = c.size(); c.clear(); for (int i = n - 1; i >= 0; i--) { auto lower = lower_bound(c.begin(), c.end(), -t[i] + d); ans = max(ans, pref[i] + (int) (lower - c.begin())); auto clower = lower_bound(c.begin(), c.end(), -t[i]); if (clower == c.end()) c.emplace_back(-t[i]); else *clower = -t[i]; } printf("%d", ans); }

Compilation message (stderr)

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