Submission #617388

#TimeUsernameProblemLanguageResultExecution timeMemory
617388Abrar_Al_SamitFinancial Report (JOI21_financial)C++17
14 / 100
225 ms1484 KiB
#include<bits/stdc++.h>
using namespace std;

void PlayGround() {
  int n, D;
  cin>>n>>D;
  int a[n+1];
  for(int i=1; i<=n; ++i) {
    cin>>a[i];
  }  

  int ans = 0;
  for(int mask=1; mask<(1<<n); ++mask) {
    vector<int>seq;
    for(int j=0; j<n; ++j) if(mask>>j&1) {
      seq.push_back(j+1);
    }
    bool ok = 1;
    for(int j=1; j<seq.size(); ++j) {
      ok &= seq[j]-seq[j-1]<=D;
    }
    if(!ok) continue;

    int cur = 0;
    int mx = -1;
    for(int j : seq) {
      if(a[j]>mx) {
        ++cur;
        mx = a[j];
      }
    }
    ans = max(ans, cur);
  }
  cout<<ans<<'\n';

}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  PlayGround();
  return 0;
}

Compilation message (stderr)

Main.cpp: In function 'void PlayGround()':
Main.cpp:19:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int j=1; j<seq.size(); ++j) {
      |                  ~^~~~~~~~~~~
#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...