답안 #674363

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
674363 2022-12-23T19:39:20 Z __Davit__ 메기 농장 (IOI22_fish) C++17
9 / 100
80 ms 14028 KB
#pragma once

#include <bits/stdc++.h>


#define ll long long
#define lld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define vr(v) v.begin(),v.end()
#define rv(v) v.rbegin(),v.rend()
#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define Davit cout.tie(NULL);

using namespace std;
const ll mod = 1e9 + 7;
const int INF = 1e9;

using namespace std;

long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
    bool isok = 1;
    bool isok2 = 1;
    bool isok3 = 1;
    for (int i = 0; i < M; i++) {
        if (X[i] & 1)isok = 0;
        if (X[i] > 1)isok2 = 0;
        if (Y[i] >= 1)isok3 = 0;
    }
    if (isok) return accumulate(W.begin(), W.end(), 0ll);
    if (isok2) {
        ll res = 0;
        vector<ll> p1(N), p2(N);
        for (int i = 0; i < M; ++i) {
            if (X[i] == 0)p1[Y[i]] = W[i];
            if (X[i] == 1)p2[Y[i]] = W[i];
        }
        for (int i = 1; i < N; i++) {
            p1[i] += p1[i - 1];
            p2[i] += p2[i - 1];
        }
        res = max(p1[N - 1], p2[N - 1]);
        if (N > 2) {
            for (int i = 0; i < N; i++) res = max(res, p2[N - 1] + p1[i] - p2[i]);
        }
        return res;
    }
    if (isok3) {
        vector<ll> dp(N, 0);
        dp[0] = 0;
        dp[1] = max(W[0], W[1]);
        vector<ll> v(N);
        for (int i = 0; i < M; i++) v[X[i]] = W[i];
        for (int i = 2; i < N; i++) {
            dp[i] = max(dp[i - 1], dp[i - 2]);
            dp[i] = max(dp[i], dp[i - 2] + max(v[i], v[i - 1]));
            if (i - 3 >= 0) {
                dp[i] = max(dp[i], dp[i - 3] + v[i] + v[i - 2]);
            } else dp[i] = max(dp[i], v[i] + v[i - 2]);
        }
        for (int i = 0; i < N; i++)cout << dp[i] << " ";
        return dp[N - 1];
    }

}
//10 9
//0 0 1
//1 0 1
//2 0 1
//3 0 1
//4 0 10
//5 0 1
//6 0 1
//7 0 1
//8 0 1

Compilation message

fish.cpp:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:68:1: warning: control reaches end of non-void function [-Wreturn-type]
   68 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 3528 KB Output is correct
2 Correct 28 ms 4280 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 78 ms 13636 KB Output is correct
6 Correct 80 ms 14028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 48 ms 8212 KB Output is correct
3 Correct 56 ms 9932 KB Output is correct
4 Correct 21 ms 3532 KB Output is correct
5 Correct 27 ms 4300 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 228 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 24 ms 4948 KB Output is correct
13 Correct 28 ms 5836 KB Output is correct
14 Correct 24 ms 4956 KB Output is correct
15 Correct 27 ms 5448 KB Output is correct
16 Correct 25 ms 4964 KB Output is correct
17 Correct 27 ms 5440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 10 ms 2516 KB Possible tampering with the output
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Possible tampering with the output
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Possible tampering with the output
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Possible tampering with the output
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 10 ms 2516 KB Possible tampering with the output
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 3528 KB Output is correct
2 Correct 28 ms 4280 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 78 ms 13636 KB Output is correct
6 Correct 80 ms 14028 KB Output is correct
7 Correct 0 ms 296 KB Output is correct
8 Correct 48 ms 8212 KB Output is correct
9 Correct 56 ms 9932 KB Output is correct
10 Correct 21 ms 3532 KB Output is correct
11 Correct 27 ms 4300 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 228 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 24 ms 4948 KB Output is correct
19 Correct 28 ms 5836 KB Output is correct
20 Correct 24 ms 4956 KB Output is correct
21 Correct 27 ms 5448 KB Output is correct
22 Correct 25 ms 4964 KB Output is correct
23 Correct 27 ms 5440 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Incorrect 10 ms 2516 KB Possible tampering with the output
26 Halted 0 ms 0 KB -