Submission #1097022

#TimeUsernameProblemLanguageResultExecution timeMemory
1097022ivazivaRabbit Carrot (LMIO19_triusis)C++14
100 / 100
56 ms4300 KiB
#include <bits/stdc++.h> using namespace std; #define MAXN 200001 int n,m; int a[MAXN]; vector<int> dp; int main() { cin>>n>>m; for (int i=1;i<=n;i++) cin>>a[i]; for (int i=0;i<=n;i++) a[i]+=m*(n-i); for (int i=0;i<=n;i++) a[i]=a[i]*(-1); dp.push_back(a[0]); for (int i=1;i<=n;i++) { int pos=upper_bound(dp.begin(),dp.end(),a[i])-dp.begin(); if (pos==dp.size()) dp.push_back(a[i]); else if (pos==0) continue; else dp[pos]=a[i]; } cout<<n+1-dp.size()<<endl; }

Compilation message (stderr)

triusis.cpp: In function 'int main()':
triusis.cpp:21:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         if (pos==dp.size()) dp.push_back(a[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...