제출 #775787

#제출 시각아이디문제언어결과실행 시간메모리
775787vgoofficialGlobal Warming (CEOI18_glo)C++14
100 / 100
53 ms5720 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(0);
    int n,x;
    cin >> n >> x;
    int temps[n];
    for(int i = 0; i < n; i++) cin >> temps[i];
    int left[n], right[n];
    vector<int> magic;
    magic.push_back(temps[0]);
    left[0]=1;
    for(int i = 1; i < n; i++) {
        int lb = lower_bound(begin(magic), end(magic), temps[i])-begin(magic);
        if(lb==magic.size()) {
            magic.push_back(temps[i]);
        } else {
            magic[lb]=temps[i];
        }
        left[i]=lb+1;
    }
    vector<int> magic2;
    magic2.push_back(-temps[n-1]);
    right[n-1]=0;
    for(int i = n-2; i >= 0; i--) {
        //for(int i: magic2) cout << i << " ";
        int rb = lower_bound(begin(magic2), end(magic2), -temps[i]+x)-begin(magic2);
        //cout << -temps[i]+x<< " " << rb << endl;
        right[i]=rb;
        int insert = lower_bound(begin(magic2), end(magic2), -temps[i])-begin(magic2);
        if(insert==magic2.size()) {
            magic2.push_back(-temps[i]);
        } else {
            magic2[insert]=-temps[i];
        }
    }
    int max = 0;
    for(int i = 0; i < n; i++) {
        max=std::max(max,left[i]+right[i]);
    }
    cout << max << endl;
}

컴파일 시 표준 에러 (stderr) 메시지

glo.cpp: In function 'int main()':
glo.cpp:17:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         if(lb==magic.size()) {
      |            ~~^~~~~~~~~~~~~~
glo.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         if(insert==magic2.size()) {
      |            ~~~~~~^~~~~~~~~~~~~~~
#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...