제출 #1111648

#제출 시각아이디문제언어결과실행 시간메모리
1111648vjudge1Rabbit Carrot (LMIO19_triusis)C++17
100 / 100
28 ms4324 KiB
#include<bits/stdc++.h>
using namespace std;

const bool multiTest = false;
#define task "C"
#define fi first
#define se second
#define MASK(i) (1LL << (i))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define BIT(mask, i) ((mask) >> (i) & 1)

template<typename T1, typename T2> bool minimize(T1 &a, T2 b) {
	if (a > b) a = b; else return 0; return 1;
}
template<typename T1, typename T2> bool maximize(T1 &a, T2 b) {
	if (a < b) a = b; else return 0; return 1;
}

const int MAX = 200020;
int N, M, h[MAX];

void process(void) {
	cin >> N >> M;
	for (int i = 1; i <= N; ++i) {
		cin >> h[i];
		h[i] -= i * M;
	}
	vector<int> dp;
	for (int i = N; i >= 1; --i) {
		int pos = upper_bound(all(dp), h[i]) - dp.begin();
		if (dp.size() == pos) dp.push_back(h[i]);
		else dp[pos] = h[i];
	}
	int res = 0;
	for (int i = 0; i < dp.size(); ++i) {
		if (h[0] >= dp[i]) 
			maximize(res, i + 1);
	}
	cout << N - res;
}

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	if (fopen(task".inp", "r")) {
		freopen(task".inp", "r",  stdin);
		freopen(task".out", "w", stdout);
	}

	int nTest = 1; if (multiTest) cin >> nTest;
	while (nTest--) {
		process();
	}

	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

triusis.cpp: In function 'void process()':
triusis.cpp:32:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |   if (dp.size() == pos) dp.push_back(h[i]);
      |       ~~~~~~~~~~^~~~~~
triusis.cpp:36:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |  for (int i = 0; i < dp.size(); ++i) {
      |                  ~~^~~~~~~~~~~
triusis.cpp: In function 'int main()':
triusis.cpp:46:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |   freopen(task".inp", "r",  stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:47:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |   freopen(task".out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...