Submission #942500

#TimeUsernameProblemLanguageResultExecution timeMemory
942500mannshah1211Rabbit Carrot (LMIO19_triusis)C++17
100 / 100
22 ms4624 KiB
/**
 *   author: hashman
 *   created: 
**/
#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

int lis(const vector<int>& a, int x) {
	vector<int> ret;
	ret.push_back(x);
	for (int i = 0; i < a.size(); i++) {
		int it = a[i];
		auto pos = lower_bound(ret.begin(), ret.end(), it + 1);
		if (pos == ret.end()) {
			ret.push_back(it);
		} else {
			ret[pos - ret.begin()] = it;
		}
	}
	return (int) ret.size();
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> foo;
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		foo.push_back((i * m) - x);
	}
	vector<int> bar;
	for (auto it : foo) {
		if (it >= 0) bar.push_back(it);
	}
	cout << n + 1 - lis(bar, 0) << '\n';
}

Compilation message (stderr)

triusis.cpp: In function 'int lis(const std::vector<int>&, int)':
triusis.cpp:17:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for (int i = 0; i < a.size(); 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...