#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int min_subsegments_to_sort(int N, vector<int>& banknotes) {
vector<int> increasing_subsequences(N, 1);
for (int i = 1; i < N; ++i) {
for (int j = 0; j < i; ++j) {
if (banknotes[i] >= banknotes[j]) {
increasing_subsequences[i] = max(increasing_subsequences[i], increasing_subsequences[j] + 1);
}
}
}
return N - *max_element(increasing_subsequences.begin(), increasing_subsequences.end());
}
int main() {
// Input
int N;
cin >> N;
vector<int> banknotes(N);
for (int i = 0; i < N; ++i) {
cin >> banknotes[i];
}
// Output
int result = min_subsegments_to_sort(N, banknotes);
cout << result << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |