Submission #505137

#TimeUsernameProblemLanguageResultExecution timeMemory
505137trumchepcodeRabbit Carrot (LMIO19_triusis)C++17
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> using namespace std; const int N=2e5+1; int a[N],n,m; vector<int> v; auto nen_so(vector<int>v) { set<int>st; for(int x:v) st.insert(x); map<int,int>mp; int cnt=1; for(auto x:st) mp[x]=cnt++; for(int i=0;i<v.size();i++) v[i]=mp[v[i]]; return v; } int bit[N]; void update(int u,int val) { for(int i=u;i<=n;i+=i&(-i)) bit[i]=val; } int get(int u) { int ans=0; for(int i=u;i>0;i-=i&(-i)) ans=max(ans,bit[i]); return ans; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("test.inp","r",stdin); // freopen("test.out","w",stdout); cin >> n >> m; for(int i=1; i<=n; i++) { cin >> a[i]; a[i]=m*i-a[i]; } for(int i=1;i<=n;i++) { if(a[i]>=0) v.push_back(a[i]); } auto ds=nen_so(v); for(int x:ds) { update(x,get(x)+1); } cout << n-get(n); }

Compilation message (stderr)

triusis.cpp: In function 'auto nen_so(std::vector<int>)':
triusis.cpp:13:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for(int i=0;i<v.size();i++) v[i]=mp[v[i]];
      |                 ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...