답안 #729753

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
729753 2023-04-24T13:16:37 Z Nahian9696 메기 농장 (IOI22_fish) C++17
18 / 100
99 ms 13880 KB
#include "fish.h"

#include <vector>
#include <bits/stdc++.h>

using namespace std;


#define f0(i, n) for(int i = 0; i <  (n); i++)
#define f1(i, n) for(int i = 1; i <= (n); i++)
#define pb push_back
#define ff first
#define ss second

typedef vector<int> vi;
typedef long long ll;



long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
                      std::vector<int> W) {
    bool allxeven = true;
    bool allxleq1 = true;
    bool ally0 = true;

    f0(i, M) {
        if(X[i] % 2 == 1) allxeven = false;
        if(X[i] > 1) allxleq1 = false;
        if(Y[i] != 0) ally0 = false;
    }


    if (allxeven) {
        ll ret = 0;
        f0(i, M) ret += W[i];
        return ret;
    } 
    if(allxleq1) {
        ll ret = 0;
        ll ans = 0;
        int arr[N][2];
        f0(i, N) arr[i][0] = 0, arr[i][1] = 0;
        f0(i, M) {
            arr[Y[i]][X[i]] = W[i];
        }

        if(N == 2) {
            return max(arr[0][0] + arr[1][0], arr[0][1] + arr[1][1]);
        }

        f0(i, N) {
            ans += arr[i][1];
        }
        ret = ans;
        f0(i, N) {
            ans -= arr[i][1];
            ans += arr[i][0];
            ret = max(ret, ans);
        }
        return ret;
    }
    if(ally0) {
        int arr[N];
        f0(i, N) arr[i] = 0;
        f0(i, M) arr[X[i]] = W[i];
        ll dp[N][4];
        dp[0][0] = -1e18;
        dp[0][1] = -1e18;
        dp[0][2] = 0;
        dp[0][3] = arr[0];

        dp[1][0] = 0;
        dp[1][1] = arr[1];
        dp[1][2] = arr[0];
        dp[1][3] = -1e18;


        f1(i, N-2) {
            dp[i+1][0] = max(dp[i][0], dp[i][2]);
            dp[i+1][1] = max(dp[i][0], dp[i][2]) + arr[i+1];
            dp[i+1][2] = max(dp[i][1], dp[i][3]);
            dp[i+1][3] = dp[i][1] + arr[i+1];
        }
        return max({
            dp[N-1][0],
            dp[N-1][1],
            dp[N-1][2]
        });
    }


    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 3552 KB Output is correct
2 Correct 35 ms 4280 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 99 ms 13652 KB Output is correct
6 Correct 95 ms 13880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 51 ms 7600 KB Output is correct
3 Correct 69 ms 9156 KB Output is correct
4 Correct 23 ms 3540 KB Output is correct
5 Correct 32 ms 4260 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 216 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 22 ms 4320 KB Output is correct
13 Correct 29 ms 5104 KB Output is correct
14 Correct 24 ms 4308 KB Output is correct
15 Correct 28 ms 4680 KB Output is correct
16 Correct 23 ms 4300 KB Output is correct
17 Correct 28 ms 4684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 420 KB Output is correct
2 Correct 3 ms 3752 KB Output is correct
3 Correct 18 ms 5580 KB Output is correct
4 Correct 12 ms 5204 KB Output is correct
5 Correct 29 ms 7732 KB Output is correct
6 Correct 24 ms 7100 KB Output is correct
7 Correct 28 ms 7608 KB Output is correct
8 Correct 28 ms 7604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 420 KB Output is correct
2 Correct 3 ms 3752 KB Output is correct
3 Correct 18 ms 5580 KB Output is correct
4 Correct 12 ms 5204 KB Output is correct
5 Correct 29 ms 7732 KB Output is correct
6 Correct 24 ms 7100 KB Output is correct
7 Correct 28 ms 7608 KB Output is correct
8 Correct 28 ms 7604 KB Output is correct
9 Incorrect 26 ms 3896 KB 1st lines differ - on the 1st token, expected: '99999', found: '0'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 3552 KB Output is correct
2 Correct 35 ms 4280 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 99 ms 13652 KB Output is correct
6 Correct 95 ms 13880 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 51 ms 7600 KB Output is correct
9 Correct 69 ms 9156 KB Output is correct
10 Correct 23 ms 3540 KB Output is correct
11 Correct 32 ms 4260 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 216 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 22 ms 4320 KB Output is correct
19 Correct 29 ms 5104 KB Output is correct
20 Correct 24 ms 4308 KB Output is correct
21 Correct 28 ms 4680 KB Output is correct
22 Correct 23 ms 4300 KB Output is correct
23 Correct 28 ms 4684 KB Output is correct
24 Correct 2 ms 420 KB Output is correct
25 Correct 3 ms 3752 KB Output is correct
26 Correct 18 ms 5580 KB Output is correct
27 Correct 12 ms 5204 KB Output is correct
28 Correct 29 ms 7732 KB Output is correct
29 Correct 24 ms 7100 KB Output is correct
30 Correct 28 ms 7608 KB Output is correct
31 Correct 28 ms 7604 KB Output is correct
32 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
33 Halted 0 ms 0 KB -