제출 #595432

#제출 시각아이디문제언어결과실행 시간메모리
595432bLICGlobal Warming (CEOI18_glo)C++17
100 / 100
57 ms5412 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sz(x) (int)(x).size() #define ft first #define sd second #define pb push_back #define endl '\n' typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<pii> vii; typedef vector<ll> vl; typedef pair<ll, ll> pll; typedef vector<pll> vll; typedef vector<vi> vvi; #define dbg if(1) void printbit(int x) {string s="\n";while(x){s+=((x%2)?'1':'0');x/=2;} reverse(all(s)); cout<<s;} const ll MOD = 1e9+7; const int INF = 1e9; const int N = 2501; void solve(){ int n, k; cin>>n>>k; vi a(n); for (int i =0;i<n;i++) cin>>a[i]; vector<int> s(n+1, INF); vii pref(n+1, {0,INF}); int ans = 0; for (int i = 0;i<n;i++){ int pos = lower_bound(all(s), a[i])-s.begin(); s[pos] = a[i]; pref[i] = {pos+1, a[i]}; ans = max(ans, pos+1); } for (int i = 0; i < n; i++) a[i]*=-1; s.clear(); s.resize(n+1, INF); for (int i = n-1;i>=0;i--){ int pos = lower_bound(all(s), a[i]+k)-s.begin(); ans = max(ans, pref[i].ft+pos); pos = lower_bound(all(s), a[i])-s.begin(); s[pos] = a[i]; } cout<<ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); // #ifdef ONLINE_JUDGE // freopen("timeline.in", "r", stdin); // freopen("timeline.out", "w", stdout); // #endif int t = 1; // cin>>t; int i = 0; while(t--){ // cout<<"Case #"<<++i<<": "; solve(); cout<<"\n"; } }

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

glo.cpp: In function 'int main()':
glo.cpp:75:9: warning: unused variable 'i' [-Wunused-variable]
   75 |     int i = 0;
      |         ^
#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...