이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define ll long long
#define F first
#define S second
#define pb push_back
const int N=7e3+7;
int dp[N][N],v[N],a[N];
map<int,int> mp;
vector<int> vec;
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n,d;
cin>>n>>d;
for(int i=0;i<n;i++){
cin>>a[i];vec.pb(a[i]);
}
sort(vec.begin(),vec.end());
vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())));
for(int i=0;i<vec.size();i++){
v[i]=vec[i];
mp[vec[i]]=i;
}
for(int i=0;i<n;i++){
dp[i][mp[a[i]]]=1;
int ind=mp[a[i]];
for(int j=max(0,i-d);j<i;j++){
for(int k=0;k<vec.size();k++){
if(a[i]>v[k]) dp[i][ind]=max(dp[i][ind],dp[j][k]+1);
else dp[i][k]=max(dp[i][k],dp[j][k]);
}
}
}
int ans=0;
for(int i=0;i<vec.size();i++){
ans=max(ans,dp[n-1][i]);
}
cout<<ans;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int main()':
Main.cpp:24:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | for(int i=0;i<vec.size();i++){
| ~^~~~~~~~~~~
Main.cpp:32:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for(int k=0;k<vec.size();k++){
| ~^~~~~~~~~~~
Main.cpp:39:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for(int i=0;i<vec.size();i++){
| ~^~~~~~~~~~~
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |