# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
662200 | Darren0724 | Financial Report (JOI21_financial) | C++17 | 51 ms | 6872 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
const int INF=1e18;
const int mod=1e9+7;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n,k;cin>>n>>k;
if(n==k){
vector<int> v(n);
vector<int> a;
for(int i=0;i<n;i++){
cin>>v[i];
}
reverse(all(v));
for(int i=0;i<n;i++){
v[i]=-v[i];
}
for(int i=0;i<n;i++){
int p=lower_bound(all(a),v[i])-a.begin();
if(p>=a.size()){
a.push_back(v[i]);
}
else{
a[p]=v[i];
}
}
cout<<a.size()<<endl;
}
else{
vector<int> v(n);
for(int i=0;i<n;i++){
cin>>v[i];
}
int p=1<<(n-1);
int ans=0;
for(int i=0;i<p;i++){
vector<int> a;
for(int j=0;j<n-1;j++){
if(i&(1<<j)){
a.push_back(j);
}
}
a.push_back(n-1);
int m=a.size();
bool flag=1;
for(int j=1;j<m;j++){
if(a[j]-a[j-1]>k){
flag=0;
}
}
if(flag==0){
continue;
}
int mx=0;
int cnt=0;
for(int j=0;j<m;j++){
if(v[a[j]]>mx){
cnt++;
mx=v[a[j]];
}
}
ans=max(ans,cnt);
}
cout<<ans<<endl;
}
return 0;
}
Compilation message (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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |