제출 #1204506

#제출 시각아이디문제언어결과실행 시간메모리
1204506sunflowerFinancial Report (JOI21_financial)C++17
14 / 100
80 ms1608 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define MASK(x) (1LL << (x)) #define BIT(x, i) (((x) >> (i)) & 1) #define SZ(x) ((int) (x).size()) #define ALL(a) (a).begin(), (a).end() #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i) #define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; --i) #define debug(x) cout << "[" << #x << " = " << (x) << "]" << endl #define left __left #define right __right #define prev __prev #define fi first #define se second template <class X, class Y> bool maximize(X &x, Y y) { if (x < y) return x = y, true; else return false; } template <class X, class Y> bool minimize(X &x, Y y) { if (x > y) return x = y, true; else return false; } int n, maxRange; #define MAX_N 300'300 int a[MAX_N + 7]; namespace subtask1 { bool check() { return (n <= 20); } int ids[25], cnt_ids = 0; void solve() { int ans = 0; FOR(mask, 1, MASK(n) - 1) { bool ok = true; cnt_ids = 0; FOR(i, 0, n - 1) if (BIT(mask, i)) { if (cnt_ids > 0) { if (i + 1 - ids[cnt_ids] > maxRange) {ok = false; break;} } ids[++cnt_ids] = i + 1; } if (!ok) continue; int res = 1, ma = a[ids[1]]; FOR(i, 2, cnt_ids) { if (a[ids[i]] > ma) { ++res; ma = a[ids[i]]; } } maximize(ans, res); } cout << ans; } } int main() { ios_base::sync_with_stdio(false);cin.tie(nullptr); cin >> n >> maxRange; FOR(i, 1, n) cin >> a[i]; if (subtask1 :: check()) return subtask1 :: solve(), 0; return 0; } /* Discipline - Calm */
#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...