제출 #328520

#제출 시각아이디문제언어결과실행 시간메모리
328520plourde27Rabbit Carrot (LMIO19_triusis)C++17
100 / 100
39 ms7140 KiB
#include <iostream> #include <string> #include <cstring> #include <cmath> #include <vector> #include <queue> #include <set> #include <algorithm> #include <map> #include <fstream> #include <bitset> #include <unordered_map> #include <stack> #include <list> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> ii; typedef vector<ii> vii; typedef map<int, int> mii; typedef map<int, string> mis; typedef map<string, int> msi; typedef set<int> si; typedef set<ll> sl; typedef map<ll, ll> mll; typedef queue<int> qi; typedef queue<ii> qii; typedef vector<string> vs; typedef pair<ll, ll> iil; typedef priority_queue<int> pqi; typedef priority_queue<ii> pqii; typedef priority_queue<ll> pqil; typedef priority_queue<iil> pqiil; typedef vector<iil> viil; typedef vector<vi> vvi; typedef long double ld; typedef pair<int, ii> iii; typedef pair<iil, ll> iiil; typedef vector<pair<pair<int,int>,int> > viii; typedef vector<pair<pair<ll,ll>,ll> > viiil; typedef vector<vl> vvl; #define pb push_back #define mp make_pair #define rep(i, n) for (int i = 0 ; i < n ; i++) #define rrep(i, m, n) for (int i = m ; i < n ; i++) #define per(i, n) for (int i = n - 1 ; i >= 0 ; i--) #define perr(i, m, n) for (int i = n - 1 ; i >= m ; i--) #define INF 2000000000 ll MOD = 1000000007; void solve() { ll n, m; cin >> n >> m; vl a(n); rep(i, n) cin >> a[i]; vl b; rep(i, n) b.pb(m * (i+1) - a[i]); vl dp(n); rep(i, n) dp[i] = INF; int mx = -1; //rep(i, n) cout << b[i] << " "; //cout << endl; rep(i, n) { if (b[i] < 0) { continue; } int ind = upper_bound(dp.begin(), dp.end(), b[i]) - dp.begin(); //cout << ind << endl; dp[ind] = b[i]; mx = max(mx, ind); } cout << n - (mx + 1) << endl; } void querySolve() { int t; cin >> t; for (int i = 0 ; i < t ; i++) { solve(); } } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); solve(); //querySolve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...