답안 #1002407

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1002407 2024-06-19T14:19:48 Z overwatch9 메기 농장 (IOI22_fish) C++17
9 / 100
50 ms 32092 KB
#include "fish.h"

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector <vector <pair <int, ll>>> fish;
vector <vector <ll>> pfx;
int n, m;
const int maxn = 1e5 + 1;
ll dp[maxn][2][2];
bool ready[maxn][2][2];
ll cost(int i, bool l1, bool l2, bool l3) {
    if (i-1 >= 1 && !l2 && (l1 || l3) && (int)fish[i-1].size() >= 2)
        return fish[i-1][1].second;
    return 0;
}
ll solve(int i, bool l1, bool l2) {
    if (i == n+1) {
        if (l1 && !l2 && (int)fish[i-1].size() >= 2)
            return fish[i-1][1].second;
        return 0;
    }
    if (ready[i][l1][l2])
        return dp[i][l1][l2];
    ll ans = solve(i+1, l2, false) + cost(i, l1, l2, false);
    ll ans2 = solve(i+1, l2, true) + cost(i, l1, l2, true);
    ready[i][l1][l2] = true;
    dp[i][l1][l2] = max(ans, ans2);
    return max(ans, ans2);
}
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
    n = N;
    m = M;
    fish.resize(N+1);
    pfx.resize(N+1);
    for (int i = 0; i < M; i++) {
        fish[X[i] + 1].push_back({Y[i] + 1, W[i]});
    }
    // dp = vector <vector <ll>> (N+1, vector <ll> (N+1, -1));
    for (int i = 1; i <= N; i++) {
        fish[i].push_back({0, 0});
        sort(fish[i].begin(), fish[i].end());
        pfx[i].resize((int)fish[i].size() + 5, 1e18);
        for (int j = 1; j < (int)fish[i].size(); j++)
            pfx[i][j] = pfx[i][j-1] + fish[i][j].second;
    }
    return solve(1, false, false);
}
// int main() {
//     int nn, mm;
//     cin >> nn >> mm;
//     vector <int> x(mm), y(mm), w(mm);
//     for (int i = 0; i < mm; i++)
//         cin >> x[i] >> y[i] >> w[i];
//     cout << max_weights(nn, mm, x, y, w) << '\n';
// }
# 결과 실행 시간 메모리 Grader output
1 Incorrect 40 ms 28400 KB 1st lines differ - on the 1st token, expected: '40313272768926', found: '223762357'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 25688 KB Output is correct
2 Correct 21 ms 25852 KB Output is correct
3 Correct 34 ms 26456 KB Output is correct
4 Correct 31 ms 27740 KB Output is correct
5 Correct 47 ms 32092 KB Output is correct
6 Correct 48 ms 31176 KB Output is correct
7 Correct 49 ms 31856 KB Output is correct
8 Correct 50 ms 31824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 25688 KB Output is correct
2 Correct 21 ms 25852 KB Output is correct
3 Correct 34 ms 26456 KB Output is correct
4 Correct 31 ms 27740 KB Output is correct
5 Correct 47 ms 32092 KB Output is correct
6 Correct 48 ms 31176 KB Output is correct
7 Correct 49 ms 31856 KB Output is correct
8 Correct 50 ms 31824 KB Output is correct
9 Incorrect 46 ms 31572 KB 1st lines differ - on the 1st token, expected: '99999', found: '66666'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 40 ms 28400 KB 1st lines differ - on the 1st token, expected: '40313272768926', found: '223762357'
2 Halted 0 ms 0 KB -