제출 #483421

#제출 시각아이디문제언어결과실행 시간메모리
483421keertanGlobal Warming (CEOI18_glo)C++17
100 / 100
58 ms3632 KiB
#pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization ("unroll-loops") /** * If you live in imaginary world when your imaginary situation encounter in * real situation you can't enjoiy it because you have to do pending work. * {This pending work appeared because you wasted that time for your useless * imagianry thinking.} */ #include<bits/stdc++.h> using namespace std; //#define int int64_t #define all(x) x.begin(),x.end() #define all1(x) x.rbegin(),x.rend() #define sz(x) (int32_t)(x.size()) const int N=1e2; void solve(){ int n,m; cin>>n>>m; vector<int> z(n); for (int &it:z){cin>>it;} vector<int> dp; int pref[n]; for (int i=0;i<n;i++){ int pos=lower_bound(all(dp),z[i])-dp.begin(); pref[i]=pos+1; if (pos==sz(dp)){ dp.push_back(z[i]); } else{ dp[pos]=z[i]; } } dp.clear(); int ans=0; for (int i=n-1;~i;i--){ int pos=lower_bound(all(dp),-z[i]+m)-dp.begin(); ans=max(ans,pref[i]+pos); pos=lower_bound(all(dp),-z[i])-dp.begin(); if (pos==sz(dp)){ dp.push_back(-z[i]); } else{ dp[pos]=-z[i]; } } cout<<ans; } int32_t main(){ ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); int tq=1; //cin>>tq; for (;tq;tq--){solve();} } //is a bruteforce possible? //think greedier, make more assumptions // if we you find solution using loop to decrease complexity use bs //stuck for more than 5 minutes? move on

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

glo.cpp:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    3 | #pragma GCC optimization ("unroll-loops")
      |
#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...