답안 #1032852

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1032852 2024-07-24T09:54:50 Z Mr_Husanboy 메기 농장 (IOI22_fish) C++17
0 / 100
877 ms 2097152 KB
#include "fish.h"
#include <bits/stdc++.h>
 
using namespace std;
 
#define ff first
#define ss second
#define all(a) (a).begin(), (a).end()
#define ll long long
 
template<typename T>
int len(T &a){
    return a.size();
}
 
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

 
long long max_weights(int n, int m, std::vector<int> x, std::vector<int> y,
                      std::vector<int> w) {
    vector<vector<ll>> s(n + 1, vector<ll> (n + 1));

    for(int i = 0; i < m; i ++) s[x[i] + 1][y[i] + 1] = w[i];
    for(int i = 1; i <= n; i ++) for(int j = 1; j <= n; j ++) s[i][j] += s[i][j - 1];

    vector<vector<array<ll, 2>>> dp(n + 1, vector<array<ll, 2>>(n + 1));
    
    for(int i = 2; i <= n; i ++){
        for(int j = 0; j <= n; j ++){
            for(int k = 0; k < j; k ++){
                dp[i][j][0] = max(dp[i][j][0], max(dp[i - 2][k][0], dp[i - 2][k][1]) + s[i - 1][j]);
            }
            dp[i][j][1] = dp[i][j][0];
            for(int k = 0; k <= j; k ++){
                dp[i][j][0] = max(dp[i][j][0], dp[i - 1][k][0] + s[i - 1][j] - s[i - 1][k]);
            }

            for(int k = j; k <= n; k ++){
                dp[i][j][1] = max(dp[i][j][1], dp[i - 1][k][1] + s[i][k] - s[i][j]);
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i <= n; i ++){
        ans = max({ans, dp[n][i][0], dp[n][i][1]});
    }

    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 809 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 352 KB Output is correct
2 Runtime error 877 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 788 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 352 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 376 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 7 ms 856 KB Output is correct
10 Correct 31 ms 2392 KB Output is correct
11 Incorrect 5 ms 860 KB 1st lines differ - on the 1st token, expected: '278622587073', found: '277471986209'
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 352 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 376 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 7 ms 856 KB Output is correct
10 Correct 31 ms 2392 KB Output is correct
11 Incorrect 5 ms 860 KB 1st lines differ - on the 1st token, expected: '278622587073', found: '277471986209'
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 352 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 376 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 7 ms 856 KB Output is correct
10 Correct 31 ms 2392 KB Output is correct
11 Incorrect 5 ms 860 KB 1st lines differ - on the 1st token, expected: '278622587073', found: '277471986209'
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 788 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 809 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -