Submission #580447

#TimeUsernameProblemLanguageResultExecution timeMemory
580447kalash04Rabbit Carrot (LMIO19_triusis)C++17
100 / 100
36 ms5320 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; ll MOD = 1e9 + 7; void solve() { int n, m; cin >> n >> m; vector<int> poles(n); for(int &pole : poles) cin >> pole; vector<int> unchange; for(int i = 1; i <= n; i++) { int val = i * m - poles[i - 1]; if(val >= 0) unchange.push_back(val); } vector<int> dp; for(int item : unchange) { int idx = upper_bound(dp.begin(), dp.end(), item) - dp.begin(); if(idx == dp.size()) dp.push_back(item); else dp[idx] = item; } cout << n - dp.size() << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); solve(); }

Compilation message (stderr)

triusis.cpp: In function 'void solve()':
triusis.cpp:20:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     if(idx == 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...