# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
483541 | zwicky | Rabbit Carrot (LMIO19_triusis) | C++14 | 101 ms | 4244 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
using std::cout;
using std::endl;
using std::vector;
int longest_nondec_subseq(const vector<int>& seq) {
vector<int> min_endings;
for (int i : seq) {
// note that we use upper_bound instead of lower_bound bc it just has to be nondecreasing
int pos = std::upper_bound(min_endings.begin(), min_endings.end(), i) - min_endings.begin();
// standard LIS protocol
if (pos == min_endings.size()) {
min_endings.push_back(i);
} else {
min_endings[pos] = i;
}
}
return min_endings.size();
}
int main() {
int pole_num;
int jump_height;
std::cin >> pole_num >> jump_height;
vector<int> poles(pole_num);
for (int p = 0; p < pole_num; p++) {
std::cin >> poles[p];
}
vector<int> poss_unchanged;
for (int i = 1; i <= pole_num; i++) {
// only add if it has any hope of being unchanged
if (i * jump_height >= poles[i - 1]) {
poss_unchanged.push_back(i * jump_height - poles[i - 1]);
}
}
cout << pole_num - longest_nondec_subseq(poss_unchanged) << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |