Submission #662200

#TimeUsernameProblemLanguageResultExecution timeMemory
662200Darren0724Financial Report (JOI21_financial)C++17
5 / 100
51 ms6872 KiB
#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)

Main.cpp: In function 'int main()':
Main.cpp:24:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |             if(p>=a.size()){
      |                ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...