제출 #968704

#제출 시각아이디문제언어결과실행 시간메모리
968704blackslexGlobal Warming (CEOI18_glo)C++17
100 / 100
52 ms5324 KiB
#include<bits/stdc++.h>

using namespace std;

int n, d;

int main() {
    scanf("%d %d", &n, &d);
    vector<int> t(n), dp(n), dp2(n);
    for (auto &e: t) scanf("%d", &e);
    vector<int> c;
    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]), dp[i] = c.size();
        else *lower = t[i], dp[i] = lower - c.begin() + 1;
    }
    int ans = c.size(); c.clear();
    for (int i = n - 1; i >= 0; i--) {
        dp2[i] = lower_bound(c.begin(), c.end(), -t[i] + d) - c.begin();
        auto lower = lower_bound(c.begin(), c.end(), -t[i]);
        if (lower == c.end()) c.emplace_back(-t[i]);
        else *lower = -t[i];
    }
    for (int i = 0; i < n; i++) ans = max(ans, dp[i] + dp2[i]);
    printf("%d", ans);
}

컴파일 시 표준 에러 (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...