이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("O2")
#include <fstream>
#include <string>
#include <iostream>
#include <bitset>
#include <math.h>
#include <string>
#include <algorithm>
#include <assert.h>
#include<bits/stdc++.h>
#include <vector>
#include <queue>
#include<stdio.h>
#include<ctype.h>
#define ll long long
using namespace std;
ll n, m;
ll arr[200002];
vector<ll> dp;
int main(){
cin >> n >> m;
arr[0] = 0;
for (int x = 0; x < n; x++){
cin >> arr[x + 1];
}
reverse(arr, arr + (n + 1));
ll answer = n;
for (int x = 0; x <= n; x++){
int pos = upper_bound(dp.begin(), dp.end(), arr[x] + m) - dp.begin();
if (pos == 0){
if (pos == dp.size()){
dp.push_back(arr[x]);
}
else{
dp[pos] = arr[x];
}
}
else{
if (dp[pos - 1] >= arr[x] - m){
if (pos == dp.size()){
dp.push_back(arr[x]);
}
else{
dp[pos] = arr[x];
}
}
}
if (upper_bound(dp.begin(), dp.end(), m) != dp.begin()){
pos = upper_bound(dp.begin(), dp.end(), m) - dp.begin();
answer = min(answer, n - (pos + 1));
}
}
cout << answer << "\n";
}
컴파일 시 표준 에러 (stderr) 메시지
triusis.cpp: In function 'int main()':
triusis.cpp:33:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | if (pos == dp.size()){
| ~~~~^~~~~~~~~~~~
triusis.cpp:42:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
42 | if (pos == dp.size()){
| ~~~~^~~~~~~~~~~~
# | 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... |