Submission #455157

#TimeUsernameProblemLanguageResultExecution timeMemory
455157YuisuyunoGlobal Warming (CEOI18_glo)C++14
100 / 100
65 ms8540 KiB
//Nguyen Huu Hoang Minh #include <bits/stdc++.h> #define sz(x) int(x.size()) #define all(x) x.begin(),x.end() #define reset(x) memset(x, 0,sizeof(x)) #define pb push_back #define mp make_pair #define fi first #define se second #define N 200005 #define remain(x) if (x > MOD) x -= MOD #define ii pair<int, int> #define iiii pair< ii , ii > #define viiii vector< iiii > #define vi vector<int> #define vii vector< ii > #define bit(x, i) (((x) >> (i)) & 1) #define Task "test" #define int long long using namespace std; typedef long double ld; const int inf = 1e10; const int minf = -1e10; int n, x; int a[N]; void readfile() { ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); if (fopen(Task".inp","r")) { freopen(Task".inp","r",stdin); //freopen(Task".out","w",stdout); } cin >> n >> x; for(int i=1; i<=n; i++) cin >> a[i]; } int L[N]; int R[N]; void proc() { vector<int> b(n+1,inf); b[0] = minf; for(int i=1; i<=n; i++){ int k = lower_bound(all(b),a[i])-b.begin(); L[i] = k; b[k] = a[i]; } //for(int i=1; i<=n; i++) cout << L[i] << ' '; b = vector<int>(n+1,inf); int ans=0; for(int i=n; i>=1; i--){ int k = lower_bound(all(b),-a[i]+x)-b.begin(); //cout << k << " \n"[i==1]; ans = max(ans,L[i]+k); k = lower_bound(all(b),-a[i])-b.begin(); b[k] = -a[i]; } cout << ans; } signed main() { readfile(); proc(); return 0; }

Compilation message (stderr)

glo.cpp: In function 'void readfile()':
glo.cpp:36:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         freopen(Task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...