답안 #1042015

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1042015 2024-08-02T12:15:32 Z VMaksimoski008 메기 농장 (IOI22_fish) C++17
12 / 100
46 ms 7292 KB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
    int mask = 0, mx = 0;
    for(int i=0; i<M; i++) mask |= (1 << (X[i] % 2));
    for(int i=0; i<M; i++) mx = max(mx, Y[i]);

    if(mask == 1) {
        ll ans = 0;
        for(int &x : W) ans += x;
        return ans;
    }

    if(mx == 0) {
        vector<ll> val(N+5), dp(N+5);
        for(int i=0; i<M; i++) val[X[i]] = W[i];

        ll ans = 0;
        vector<ll> MX(N+5); MX[0] = val[1];
        //dp[i] - poslednata kula e na i
        for(int i=1; i<N; i++) {
            dp[i] = max(dp[i-1], val[i-1]);
            if(i >= 3) dp[i] = max(dp[i], MX[i-3] + val[i-1]);
            // for(int j=i-3; j>=0; j--) dp[i] = max(dp[i], val[i-1] + dp[j] + val[j+1]);
            if(i >= 2) dp[i] = max(dp[i], dp[i-2] + val[i-1]);
            MX[i] = max(MX[i-1], dp[i] + val[i+1]);
        }

        // for(int i=0; i<N; i++) cout << val[i] << " ";
        // cout << '\n';
        // for(int i=0; i<N; i++) cout << dp[i] << " ";
        // cout << '\n';
        for(int i=0; i<N; i++) ans = max(ans, dp[i] + val[i+1]);
        return ans;
    }


    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 2140 KB Output is correct
2 Correct 14 ms 2648 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 45 ms 7292 KB Output is correct
6 Correct 46 ms 7288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '2', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 9 ms 4520 KB Output is correct
4 Correct 8 ms 4188 KB Output is correct
5 Correct 16 ms 6712 KB Output is correct
6 Correct 13 ms 5924 KB Output is correct
7 Correct 16 ms 6600 KB Output is correct
8 Correct 16 ms 6488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 9 ms 4520 KB Output is correct
4 Correct 8 ms 4188 KB Output is correct
5 Correct 16 ms 6712 KB Output is correct
6 Correct 13 ms 5924 KB Output is correct
7 Correct 16 ms 6600 KB Output is correct
8 Correct 16 ms 6488 KB Output is correct
9 Incorrect 13 ms 3924 KB 1st lines differ - on the 1st token, expected: '99999', found: '0'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 2140 KB Output is correct
2 Correct 14 ms 2648 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 45 ms 7292 KB Output is correct
6 Correct 46 ms 7288 KB Output is correct
7 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '2', found: '0'
8 Halted 0 ms 0 KB -