제출 #934018

#제출 시각아이디문제언어결과실행 시간메모리
934018Amirreza_FakhriGlobal Warming (CEOI18_glo)C++17
100 / 100
42 ms4304 KiB
// In the name of the God
#include <bits/stdc++.h>
#define ll long long
// #define int long long
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define pii pair <int, int>
#define smin(x, y) (x) = min((x), (y))
#define smax(x, y) (x) = max((x), (y))
#define all(x) (x).begin(), (x).end()
using namespace std;

const int inf = 1e9+7;
const int mod = 998244353;
const int maxn = 2e5+5;

int n, x, a[maxn], b[maxn];
vector <int> vec;

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> x;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        int j = lower_bound(all(vec), a[i]+x)-vec.begin();
        b[i] = j+1;
        j = lower_bound(all(vec), a[i])-vec.begin();
        if (j == vec.size()) vec.pb(a[i]);
        else vec[j] = a[i];
    }
    vec.clear();
    int ans = 0;
    for (int i = n-1; i >= 0; i--) {
        int j = lower_bound(all(vec), -a[i])-vec.begin();
        if (j == vec.size()) vec.pb(-a[i]);
        else vec[j] = -a[i];
        smax(ans, b[i]+j);
    }
    cout << ans << '\n';
    return 0;
}






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

glo.cpp: In function 'int32_t main()':
glo.cpp:30:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         if (j == vec.size()) vec.pb(a[i]);
      |             ~~^~~~~~~~~~~~~
glo.cpp:37:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         if (j == vec.size()) vec.pb(-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...