Submission #811971

# Submission time Handle Problem Language Result Execution time Memory
811971 2023-08-07T06:38:19 Z vjudge1 Financial Report (JOI21_financial) C++17
0 / 100
4000 ms 1492 KB
#ifdef Home
#define _GLIBCXX_DEBUG
#endif // Home

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

int lg2(int x) {
    return 31 - __builtin_clz(x);
}

main() {
#ifdef Home
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // Home
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n, d;
    cin >> n >> d;
    int arr[n];
    for(int i = 0; i < n; ++ i) {
        cin >> arr[i];
    }
    int ans = 0;
    for(int msk = (1<<n); msk --> 0;) {
        int k = 0;
        for(int tmp = msk, pr = -1, cr, mx = 0; tmp >= (1<<(n - 1)); tmp -= (-tmp&tmp)) {
            cr = lg2(-tmp&tmp);
            if(pr != -1 && cr - pr > d) {
                k = 0;
                break;
            }
            if(mx < arr[cr]) {
                ++ k;
                mx = arr[cr];
            }
            pr = cr;
        }
        ans = max(ans, k);
    }
    cout  << ans;
}

Compilation message

Main.cpp:16:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   16 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4033 ms 1364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4030 ms 1492 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -