Submission #584560

#TimeUsernameProblemLanguageResultExecution timeMemory
584560BhavayGoyalRabbit Carrot (LMIO19_triusis)C++14
100 / 100
27 ms5284 KiB
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define ll long long #define ld long double #define ar array #define vi vector<int> #define vii vector<vector<int>> #define pii pair<int, int> #define pb push_back #define all(x) x.begin(), x.end() #define f first #define s second const int MOD = 1e9+7; const int inf = 1e9; const ll linf = 1e18; const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1}; const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1}; // -------------------------------------------------- Main Code -------------------------------------------------- int lis(vi &arr) { vi dp; for (int i = 0; i < arr.size(); i++) { int x = upper_bound(all(dp), arr[i]) - dp.begin(); if (x == dp.size()) dp.pb(arr[i]); else dp[x] = arr[i]; } return dp.size(); } void sol() { int n, m; cin >> n >> m; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; vi a; for (int i = 1; i <= n; i++) { if (m*i - arr[i-1] >= 0) { a.pb(m*i - arr[i-1]); } } cout << n-lis(a) << endl; } int main () { ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; // cin >> t; while (t--) { sol(); } return 0; }

Compilation message (stderr)

triusis.cpp: In function 'int lis(std::vector<int>&)':
triusis.cpp:34:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for (int i = 0; i < arr.size(); i++) {
      |                     ~~^~~~~~~~~~~~
triusis.cpp:36:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         if (x == dp.size()) dp.pb(arr[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...