Submission #485934

#TimeUsernameProblemLanguageResultExecution timeMemory
485934ManagerGlobal Warming (CEOI18_glo)C++14
0 / 100
2076 ms1884 KiB
#include <bits/stdc++.h> #include <random> #include <ext/pb_ds/assoc_container.hpp> #define clr(X , val) memset(X , val , sizeof(X)) #define all(X) (X).begin() , (X).end() #define rall(X) (X).rbegin() , (X).rend() #define sz(X) (int)X.size() //#define Judge #define int intmax_t #define mp make_pair #define endl '\n' #define tab '\t' using namespace std; using namespace __gnu_pbds; mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count()); template <class T> inline bool isSquare(T n) { T s = sqrt(n); return s * s == n || (s + 1) * (s + 1) == n; } typedef long long ll; typedef unsigned long long ull; template < class T > using indexed_set = tree < T , null_type , less < T > , rb_tree_tag , tree_order_statistics_node_update >; template < class T > using indexed_multiset = tree < T , null_type , less_equal < T > , rb_tree_tag , tree_order_statistics_node_update >; constexpr int maxN = 1e5 + 10; const string alpha = "abcdefghijklmnopqrstuvwxyz"; const string an_alpha = "qwertyuiopasdfghjkl;zxcvbnm,./"; constexpr long double EPS = 1e-8; const ll INF = 1e18 + 5; void solve() { int n , x; cin >> n >> x; vector < int > ar(n); for (auto &i : ar) cin >> i; auto lis = [](auto &ar){ vector < int > st; for (int i = (int)ar.size() - 1;i >= 0;--i){ auto pos = upper_bound(all(st) , ar[i]); if (pos == st.end()) st.emplace_back(ar[i]); else{ *pos = ar[i]; } } return st.size(); }; int lis_max = lis(ar); for (int i = n - 1;i >= 0;--i){ ar[i] -= x; lis_max = max(lis_max , (int)lis(ar)); } cout << lis_max << endl; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t = 1; #ifdef Judge freopen("socdist.in" , "r" , stdin); freopen("socdist.out" , "w" , stdout); #endif //cin >> t; while (t--){ solve(); } return 0; } /* stuff you should look for * int overflow, array bounds * SPECIAL CASES (n=1?) * do smth instead of nothing and stay organized * WRITE STUFF DOWN * DON'T GET STUCK ON ONE APPROACH */
#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...