Submission #1301179

#TimeUsernameProblemLanguageResultExecution timeMemory
1301179shk1384Rabbit Carrot (LMIO19_triusis)C++20
100 / 100
21 ms6648 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define F first #define S second #define all(x) x.begin(), x.end() #define pii pair<int, int> #define pll pair<long long, long long> #define pb(x) push_back(x) #define mp(x, y) make_pair(x, y) void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;} void __print(float x) {cerr << x;} void __print(double x) {cerr << x;} void __print(long double x) {cerr << x;} void __print(char x) {cerr << '\'' << x << '\'';} void __print(const char *x) {cerr << '\"' << x << '\"';} void __print(const string &x) {cerr << '\"' << x << '\"';} void __print(bool x) {cerr << (x ? "true" : "false");} template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';} template<typename T> void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";} template <typename T, typename... V> void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);} #define dbg(x...) cerr << "\e[91m"<<__func__<<":"<<__LINE__<<" [" << #x << "] = ["; _print(x); cerr << "\e[39m" << endl; const int N=1e6+10; //const ll mod=998244353; const ll mod=1000000007; const int intinf=2e9; const ll llinf=9e18; const ld eps=2e-7; ll n, m; void solve(){ cin >> n >> m; vector<ll> a(n + 1); a[0] = 0; for(int i = 1; i <= n; i++) cin >> a[i]; n++; vector<ll> A; for(int i = 0; i < n; i++){ a[i] = m * i - a[i]; if(a[i] >= 0) A.pb(a[i]); } vector<ll> dp; for(ll x : A){ ll pos = upper_bound(all(dp), x) - dp.begin(); if(pos == dp.size()) dp.pb(x); else dp[pos] = x; } cout << n - dp.size() << "\n"; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int t=1; //cin >> t; while(t--) solve(); return 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...