Submission #570616

#TimeUsernameProblemLanguageResultExecution timeMemory
570616BlagojceGlobal Warming (CEOI18_glo)C++11
27 / 100
118 ms5896 KiB
#include <bits/stdc++.h> #define fr(i, n, m) for(int i = (n); i < (m); i ++) #define st first #define nd second #define all(x) begin(x), end(x) #define pb push_back #define pq priority_queue using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; const int mxn = 2e5; const ll inf = 1e9; const ld eps =1e-9; int lis(vector<int> const& a) { int n = a.size(); const int INF = 1e9; vector<int> d(n+1, INF); d[0] = -INF; for (int i = 0; i < n; i++) { int j = upper_bound(d.begin(), d.end(), a[i]) - d.begin(); if (d[j-1] < a[i] && a[i] < d[j]) d[j] = a[i]; } int ans = 0; for (int i = 0; i <= n; i++) { if (d[i] < INF) ans = i; } return ans; } int main(){ int n, x; cin >> n >> x; int a[n]; fr(i, 0, n){ cin >> a[i]; } vector<int> newv; fr(i, 0, n){ if(x != 0) newv.pb(a[i]+x); newv.pb(a[i]); if(x != 0) newv.pb(a[i]-x); } cout<<lis(newv)<<endl; }
#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...