Submission #413262

#TimeUsernameProblemLanguageResultExecution timeMemory
413262kwongwengRabbit Carrot (LMIO19_triusis)C++17
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef pair<ll, ll> pll; #define FOR(i,a,b) for (int i = a; i < b; i++) #define ROF(i,a,b) for (int i = a; i >=b; i--) #define pb push_back #define ms memset #define F first #define S second ll MOD = 1000000007; //ll MOD = 998244353 ll power(ll base, ll n){ if (n == 0) return 1; if (n == 1) return base; ll halfn = power(base, n/2); if (n % 2 == 0) return (halfn*halfn) % MOD; return (((halfn*halfn)%MOD)*base) % MOD; } ll inverse(ll n){ return power(n, MOD-2); } ll add(ll a, ll b){ return (a+b) % MOD; } ll mul(ll a, ll b){ return (a*b) % MOD; } ll gcd(ll a, ll b){ if (a == 1) return 1; if (a == 0) return b; return gcd(b%a, a); } int main(){ ios::sync_with_stdio(false); int n, m; cin >> n >> m; vi a(n+1); FOR(i, 1, n+1) cin >> a[i]; FOR(i, 1, n+1) a[i] = i*m - a[i]; int ans = 0; vi dp; FOR(i, 1, n+1){ if (a[i] < 0) continue; int pos = lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin(); if (dp.size() == pos){ dp.pb(a[i]); }else{ dp[pos] = a[i]; } } cout << n - ans << '\n'; }

Compilation message (stderr)

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