Submission #1256340

#TimeUsernameProblemLanguageResultExecution timeMemory
1256340menkhRabbit Carrot (LMIO19_triusis)C++17
100 / 100
69 ms12872 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define MAX 200005
int poles[MAX], b[MAX];
int n, m;

void solve() {
	scanf("%lld %lld", &n, &m); 
	for (int i = 1; i <= n; i++) scanf("%lld", &poles[i]);

	for (int i = 1; i <= n; i++) b[i] = m * i - poles[i];

	multiset<int> s;
	for (int i = 1; i <= n; i++) {
		if (b[i] < 0) continue; 
		
		auto it = s.upper_bound(b[i]);
		if (it != s.end()) s.erase(it);
		s.insert(b[i]);
	}

	printf("%lld\n", n - (int)s.size());
}

signed main() {
	solve();
}

Compilation message (stderr)

triusis.cpp: In function 'void solve()':
triusis.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         scanf("%lld %lld", &n, &m);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
triusis.cpp:11:43: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         for (int i = 1; i <= n; i++) scanf("%lld", &poles[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...