답안 #892160

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
892160 2023-12-25T02:25:53 Z Peter2017 Financial Report (JOI21_financial) C++14
28 / 100
36 ms 3420 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pill pair<int,ll>
#define mem(a, b) memset(a, b, sizeof(a))
#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1)
#define name "test"

using namespace std;

const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const ll oo = 1e18 + 69;

template <typename T1, typename T2> bool maxi(T1 &a, T2 b){if (a < b){a = b; return 1;} return 0;}
template <typename T1, typename T2> bool mini(T1 &a, T2 b){if (a > b){a = b; return 1;} return 0;}

int n;
int k;
int D;
int a[N];
int f[(int)4e2 + 2][(int)4e2 + 2];
vector <int> value;

void load(){
    cin.tie(0)->sync_with_stdio(0);
    if (fopen(name".inp", "r")){
        freopen(name".inp", "r", stdin);
        freopen(name".ans", "w", stdout);
    }
}

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

void compress(){
    for (int i = 1; i <= n; i++)
        value.push_back(a[i]);
    sort(value.begin(), value.end());
    value.erase(unique(value.begin(), value.end()), value.end());
    for (int i = 1; i <= n; i++)
        a[i] = lower_bound(value.begin(), value.end(), a[i]) - value.begin() + 1;
    k = (int)value.size();
}

void solve(){
    compress();
    mem(f, -0x3f);
    for (int i = 1; i <= n; i++){
        f[i][a[i]] = 1;
        for (int j = i - 1; j >= max(1, i - D); j--){
            for (int x = 1; x <= k; x++){
                maxi(f[i][max(x,a[i])], f[j][x] + (x < a[i]));
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= k; i++)
        maxi(ans, f[n][i]);
    cout << ans;
}

int main(){
    load();
    input();
    solve();
}

Compilation message

Main.cpp: In function 'void load()':
Main.cpp:32:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         freopen(name".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:33:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         freopen(name".ans", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 860 KB Output is correct
2 Correct 0 ms 860 KB Output is correct
3 Correct 0 ms 860 KB Output is correct
4 Correct 0 ms 860 KB Output is correct
5 Correct 0 ms 860 KB Output is correct
6 Correct 0 ms 860 KB Output is correct
7 Correct 0 ms 860 KB Output is correct
8 Correct 0 ms 860 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 856 KB Output is correct
13 Correct 0 ms 860 KB Output is correct
14 Correct 0 ms 860 KB Output is correct
15 Correct 1 ms 860 KB Output is correct
16 Correct 0 ms 860 KB Output is correct
17 Correct 0 ms 860 KB Output is correct
18 Correct 1 ms 860 KB Output is correct
19 Correct 1 ms 860 KB Output is correct
20 Correct 1 ms 860 KB Output is correct
21 Correct 0 ms 860 KB Output is correct
22 Correct 1 ms 860 KB Output is correct
23 Correct 1 ms 860 KB Output is correct
24 Correct 0 ms 860 KB Output is correct
25 Correct 1 ms 856 KB Output is correct
26 Correct 1 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 860 KB Output is correct
2 Correct 0 ms 860 KB Output is correct
3 Correct 0 ms 860 KB Output is correct
4 Correct 0 ms 860 KB Output is correct
5 Correct 0 ms 860 KB Output is correct
6 Correct 0 ms 860 KB Output is correct
7 Correct 0 ms 860 KB Output is correct
8 Correct 0 ms 860 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 856 KB Output is correct
13 Correct 0 ms 860 KB Output is correct
14 Correct 0 ms 860 KB Output is correct
15 Correct 1 ms 860 KB Output is correct
16 Correct 0 ms 860 KB Output is correct
17 Correct 0 ms 860 KB Output is correct
18 Correct 1 ms 860 KB Output is correct
19 Correct 1 ms 860 KB Output is correct
20 Correct 1 ms 860 KB Output is correct
21 Correct 0 ms 860 KB Output is correct
22 Correct 1 ms 860 KB Output is correct
23 Correct 1 ms 860 KB Output is correct
24 Correct 0 ms 860 KB Output is correct
25 Correct 1 ms 856 KB Output is correct
26 Correct 1 ms 860 KB Output is correct
27 Correct 1 ms 968 KB Output is correct
28 Correct 1 ms 860 KB Output is correct
29 Correct 1 ms 860 KB Output is correct
30 Correct 3 ms 860 KB Output is correct
31 Correct 1 ms 860 KB Output is correct
32 Correct 36 ms 1100 KB Output is correct
33 Correct 1 ms 860 KB Output is correct
34 Correct 2 ms 860 KB Output is correct
35 Correct 2 ms 860 KB Output is correct
36 Correct 7 ms 1096 KB Output is correct
37 Correct 1 ms 860 KB Output is correct
38 Correct 2 ms 860 KB Output is correct
39 Correct 4 ms 860 KB Output is correct
40 Correct 5 ms 1100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 860 KB Output is correct
2 Correct 0 ms 860 KB Output is correct
3 Correct 0 ms 860 KB Output is correct
4 Correct 0 ms 860 KB Output is correct
5 Correct 0 ms 860 KB Output is correct
6 Correct 0 ms 860 KB Output is correct
7 Correct 0 ms 860 KB Output is correct
8 Correct 0 ms 860 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 856 KB Output is correct
13 Correct 0 ms 860 KB Output is correct
14 Correct 0 ms 860 KB Output is correct
15 Correct 1 ms 860 KB Output is correct
16 Correct 0 ms 860 KB Output is correct
17 Correct 0 ms 860 KB Output is correct
18 Correct 1 ms 860 KB Output is correct
19 Correct 1 ms 860 KB Output is correct
20 Correct 1 ms 860 KB Output is correct
21 Correct 0 ms 860 KB Output is correct
22 Correct 1 ms 860 KB Output is correct
23 Correct 1 ms 860 KB Output is correct
24 Correct 0 ms 860 KB Output is correct
25 Correct 1 ms 856 KB Output is correct
26 Correct 1 ms 860 KB Output is correct
27 Correct 1 ms 968 KB Output is correct
28 Correct 1 ms 860 KB Output is correct
29 Correct 1 ms 860 KB Output is correct
30 Correct 3 ms 860 KB Output is correct
31 Correct 1 ms 860 KB Output is correct
32 Correct 36 ms 1100 KB Output is correct
33 Correct 1 ms 860 KB Output is correct
34 Correct 2 ms 860 KB Output is correct
35 Correct 2 ms 860 KB Output is correct
36 Correct 7 ms 1096 KB Output is correct
37 Correct 1 ms 860 KB Output is correct
38 Correct 2 ms 860 KB Output is correct
39 Correct 4 ms 860 KB Output is correct
40 Correct 5 ms 1100 KB Output is correct
41 Runtime error 8 ms 3420 KB Execution killed with signal 11
42 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 16 ms 2140 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 19 ms 2140 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 860 KB Output is correct
2 Correct 0 ms 860 KB Output is correct
3 Correct 0 ms 860 KB Output is correct
4 Correct 0 ms 860 KB Output is correct
5 Correct 0 ms 860 KB Output is correct
6 Correct 0 ms 860 KB Output is correct
7 Correct 0 ms 860 KB Output is correct
8 Correct 0 ms 860 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 856 KB Output is correct
13 Correct 0 ms 860 KB Output is correct
14 Correct 0 ms 860 KB Output is correct
15 Correct 1 ms 860 KB Output is correct
16 Correct 0 ms 860 KB Output is correct
17 Correct 0 ms 860 KB Output is correct
18 Correct 1 ms 860 KB Output is correct
19 Correct 1 ms 860 KB Output is correct
20 Correct 1 ms 860 KB Output is correct
21 Correct 0 ms 860 KB Output is correct
22 Correct 1 ms 860 KB Output is correct
23 Correct 1 ms 860 KB Output is correct
24 Correct 0 ms 860 KB Output is correct
25 Correct 1 ms 856 KB Output is correct
26 Correct 1 ms 860 KB Output is correct
27 Correct 1 ms 968 KB Output is correct
28 Correct 1 ms 860 KB Output is correct
29 Correct 1 ms 860 KB Output is correct
30 Correct 3 ms 860 KB Output is correct
31 Correct 1 ms 860 KB Output is correct
32 Correct 36 ms 1100 KB Output is correct
33 Correct 1 ms 860 KB Output is correct
34 Correct 2 ms 860 KB Output is correct
35 Correct 2 ms 860 KB Output is correct
36 Correct 7 ms 1096 KB Output is correct
37 Correct 1 ms 860 KB Output is correct
38 Correct 2 ms 860 KB Output is correct
39 Correct 4 ms 860 KB Output is correct
40 Correct 5 ms 1100 KB Output is correct
41 Runtime error 8 ms 3420 KB Execution killed with signal 11
42 Halted 0 ms 0 KB -