Submission #1032438

#TimeUsernameProblemLanguageResultExecution timeMemory
1032438ArthuroWichRabbit Carrot (LMIO19_triusis)C++17
100 / 100
21 ms8540 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int void solve() { int n, m, ans = 0; cin >> n >> m; vector<int> a(n), b, dp; for (int &x : a) { cin >> x; } for (int i = 0; i < n; i++) { if (a[i] <= (i+1)*m) { b.push_back((i+1)*m-a[i]); } } for (int i : b) { int pos = upper_bound(dp.begin(), dp.end(), i) - dp.begin(); if (pos == dp.size()) { dp.push_back(i); ans = dp.size(); } else { dp[pos] = i; } } cout << n-ans << endl; } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); int t; t = 1; while(t--) { solve(); } }

Compilation message (stderr)

triusis.cpp: In function 'void solve()':
triusis.cpp:18:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         if (pos == dp.size()) {
      |             ~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...