// Author: caption_mingle
#include "bits/stdc++.h"
using namespace std;
#define ln "\n"
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define ll long long
const int mod = 1e9 + 7;
const int inf = 2e9;
const int N = 3e5 + 7;
int n, a[N], d, f[N];
multiset<int> s[N];
vector<int> vec;
struct SEGTREE {
int n;
vector<int> st;
SEGTREE(int n) : n(n) {
st.resize(n * 4 + 4, 0);
}
void update(int i, int l, int r, int u, int x) {
if(l > u or r < u) return;
if(l == r) {
st[i] = x;
return;
}
int m = (l + r) >> 1;
update(i * 2, l, m, u, x);
update(i * 2 + 1, m + 1, r, u, x);
st[i] = max(st[i * 2], st[i * 2 + 1]);
}
int get(int i, int l, int r, int u, int v) {
if(l > v or r < u) return 0;
if(u <= l and r <= v) return st[i];
int m = (l + r) >> 1;
return max(get(i * 2, l, m, u, v), get(i * 2 + 1, m + 1, r, u, v));
}
};
signed main() {
cin.tie(0) -> sync_with_stdio(0);
#define task ""
if(fopen(task ".INP", "r")) {
freopen(task ".INP", "r", stdin);
freopen(task ".OUT", "w", stdout);
}
cin >> n >> d;
for(int i = 0; i < n; i++) cin >> a[i];
int ans = 0;
for(int mask = 1; mask < (1 << n); mask++) {
int pre = -1;
bool ok = 1;
vector<int> vec;
for(int i = 0; i < n; i++) {
if(mask >> i & 1) {
if(pre != -1 and i - pre > d) {
ok = 0;
break;
}
vec.pb(a[i]);
pre = i;
}
}
if(!ok) continue;
int mx = -1;
int cur = 0;
for(int x : vec) {
if(x > mx) {
mx = x;
cur++;
}
}
ans = max(ans, cur);
}
cout << ans << ln;
cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int main()':
Main.cpp:51:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
51 | freopen(task ".INP", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:52:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
52 | freopen(task ".OUT", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |