제출 #1164707

#제출 시각아이디문제언어결과실행 시간메모리
1164707hashimaliRabbit Carrot (LMIO19_triusis)C++20
100 / 100
17 ms5052 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define endl '\n' #define ld long double #define pb push_back #define pf push_front #define mod 998244353 #define se second #define fi first #define all(ls) (ls).begin(),(ls).end() #define int long long using namespace std; using namespace __gnu_pbds; template<typename type>using ordered_set=tree<type,null_type,less<type>,rb_tree_tag,tree_order_statistics_node_update>; template<typename type>using ordered_multiset=tree<type,null_type,less_equal<type>,rb_tree_tag,tree_order_statistics_node_update>; int lengthOfLIS(vector<int>& arr) { int n = arr.size(); vector<int> ans; ans.push_back(arr[0]); for (int i = 1; i < n; i++) { if (arr[i] > ans.back()) { ans.push_back(arr[i]); } else { int low = upper_bound(ans.begin(), ans.end(), arr[i]) - ans.begin(); if(low==ans.size()) ans.pb(arr[i]); else ans[low] = arr[i]; } } return ans.size(); } void solve(){ int n,m; cin>>n>>m; vector<int>ls; for(int i=1;i<=n;i++){ int e; cin>>e; if(i*m>=e){ // cout<<(i*m)-e<<" "; ls.pb((i*m)-e); } } if(ls.size()==0){ cout<<n<<endl; return; } cout<<n-lengthOfLIS(ls)<<endl; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t=1; // cin>>t; for(int i=1;i<=t;i++){ // cout<<"Scenario #"<<i<<":"<<" "; solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...