Submission #538125

#TimeUsernameProblemLanguageResultExecution timeMemory
538125DJ035Global Warming (CEOI18_glo)C++17
38 / 100
2078 ms4372 KiB
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#include <bits/stdc++.h>
#define MEM 1111111
#define sanic ios_base::sync_with_stdio(0)
#define x first
#define y second
#define pf push_front
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz size()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll INF = 1e17+7;
const ll MOD = 998244353;
ll gcd(ll a, ll b){
    if(a%b) return gcd(b, a%b);
    return b;
}
ll t,n,m,a,b,x;
ll ls(vector<ll> l){
    ll ret=0;
    vector<int> lis;
    lis.pb(-INF);
    for(int i=0; i<n; i++){
        if(lis.back()<l[i])
            lis.pb(l[i]);
        else{
            int idx=lower_bound(lis.begin(), lis.end(), l[i])-lis.begin();
            lis[idx] = l[i];
        }
    }
    ret = lis.sz-1;
    return ret;
}
signed main(){
    sanic; cin.tie(0);
    cin >> n >> x;
    vector<ll> d;
    for(int i=0; i<n; i++){
        ll q;
        cin >> q;
        d.pb(q);
    }
    ll ans=ls(d);
    if(!x){
        cout << ans;
        return 0;
    }
    for(int j=0; j<n; j++){
        vector<ll> g;
        g = d;
        /*
        for(int l=0; l<=j; l++)
            g[l] += x;
        ans = max(ls(g), ans);
        g = d;
        */
        for(int l=0; l<=j; l++)
            g[l] -= x;
        ans = max(ls(g), ans);
    }
    cout << ans;
}

Compilation message (stderr)

glo.cpp: In function 'll ls(std::vector<long long int>)':
glo.cpp:27:12: warning: overflow in conversion from 'long long int' to 'std::vector<int>::value_type' {aka 'int'} changes value from '-100000000000000000' to '-1569325056' [-Woverflow]
   27 |     lis.pb(-INF);
      |            ^~~~
#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...