답안 #628139

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
628139 2022-08-13T06:16:56 Z TheQuantiX 메기 농장 (IOI22_fish) C++17
3 / 100
90 ms 9572 KB
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

ll n, m, x, y, k;

ll max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> k) {
    vector<ll> v(n);
    for (int i = 0; i < m; i++) {
        v[x[i]] += k[i];
    }
    vector<ll> dp1(n + 1);
    vector<ll> dp2(n + 1);
    for (int i = 1; i <= n; i++) {
        if (i != n) {
            dp2[i] = v[i - 1];
            if (i >= 2) {
                dp2[i] = max(dp2[i], dp2[i - 2] + v[i - 1]);
                dp2[i] = max(dp2[i], dp1[i - 2] + v[i - 1]);
            }
            dp2[i] = max(dp2[i], dp1[i - 1] + v[i - 1]);
        }
        if (i != 1) {
            if (i >= 3) {
                dp1[i] = max(dp2[i], dp2[i - 3] + v[i - 1]);
            }
            dp1[i] = max(dp2[i], dp2[i - 2] + v[i - 1]);
            dp1[i] = max(dp2[i], dp1[i - 2] + v[i - 1]);
        }
    }
    return max(*max_element(dp1.begin(), dp1.end()), *max_element(dp2.begin(), dp2.end()));
}

//void solve() {
//    cin >> n >> m;
//    vector<int> x(m);
//    vector<int> y(m);
//    vector<int> k(m);
//    for (int i = 0; i < m; i++) {
//        cin >> x[i] >> y[i] >> k[i];
//    }
//    cout << max_weights(n, m, x, y, k) << '\n';
//}
//
//int main() {
//    ios_base::sync_with_stdio(0);
//    cin.tie(0);
//    cout.tie(0);
//    solve();
//}
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 4300 KB Output is correct
2 Correct 45 ms 4928 KB Output is correct
3 Correct 3 ms 2644 KB Output is correct
4 Correct 3 ms 2644 KB Output is correct
5 Correct 88 ms 9572 KB Output is correct
6 Correct 90 ms 9564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2644 KB Output is correct
2 Correct 3 ms 2644 KB Output is correct
3 Incorrect 17 ms 3632 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '26722445760742'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2644 KB Output is correct
2 Correct 3 ms 2644 KB Output is correct
3 Incorrect 17 ms 3632 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '26722445760742'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 4300 KB Output is correct
2 Correct 45 ms 4928 KB Output is correct
3 Correct 3 ms 2644 KB Output is correct
4 Correct 3 ms 2644 KB Output is correct
5 Correct 88 ms 9572 KB Output is correct
6 Correct 90 ms 9564 KB Output is correct
7 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
8 Halted 0 ms 0 KB -