Submission #991248

#TimeUsernameProblemLanguageResultExecution timeMemory
991248ByeWorldRabbit Carrot (LMIO19_triusis)C++14
100 / 100
72 ms4300 KiB
#include <bits/stdc++.h> #define ll long long // #define int long long #define fi first #define se second #define pb push_back #define lf ((id<<1)) #define rg ((id<<1)|1) #define md ((l+r)>>1) using namespace std; typedef pair<ll,ll> pii; typedef pair<pii,ll> ipii; const int MAXN = 2e5+10; const ll MOD = 1e9+7; const ll INF = 1e18+10; const int LOG = 21; int n, m; int a[MAXN], b[MAXN]; signed main(){ // ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n >> m; for(int i=1; i<=n; i++) cin >> a[i]; int ans = 0; for(int i=1; i<=n; i++) a[i] -= i*m; vector <int> vec; for(int i=1; i<=n; i++){ a[i] = -a[i]; // cout << a[i] << ' '; if(a[i] < 0) continue; if(vec.empty()){ vec.pb(a[i]); continue; } int idx = upper_bound(vec.begin(), vec.end(), a[i])-vec.begin(); if(idx==vec.size()) vec.pb(a[i]); else vec[idx] = a[i]; } cout << n-vec.size() << '\n'; }

Compilation message (stderr)

triusis.cpp: In function 'int main()':
triusis.cpp:37:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   if(idx==vec.size()) vec.pb(a[i]);
      |      ~~~^~~~~~~~~~~~
triusis.cpp:26:6: warning: unused variable 'ans' [-Wunused-variable]
   26 |  int ans = 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...