# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
894052 | BBart888 | Rabbit Carrot (LMIO19_triusis) | C++14 | 21 ms | 4812 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <cstring>
#include <climits>
#include <functional>
#include<cstdlib>
//#include "arc.h"
//#include "dreaming.h"
#include <complex>
#include <array>
using namespace std;
const int MAXN = 2e5 + 12;
using ll = long long;
const int P = 31;
const ll mod1 = 1e9 + 7;
const ll mod2 = 998244353;
using ld = long double;
int n, m;
int a[MAXN];
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()
{
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
//freopen("fortmoo.in", "r", stdin);
//freopen("fortmoo.out", "w", stdout);
cin >> n >> m;
for (int i = 0; i < n; i++)
cin >> a[i];
vector<int> check;
for (int i = 1; i <= n; i++)
{
if (i * m >= a[i - 1])
check.push_back(i * m - a[i - 1]);
}
cout << n - longest_nondec_subseq(check);
return 0;
}
컴파일 시 표준 에러 (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... |