답안 #723851

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
723851 2023-04-14T11:18:39 Z vjudge1 메기 농장 (IOI22_fish) C++17
18 / 100
89 ms 12332 KB
//#include "fish.h"
#include<bits/stdc++.h>
#define ll long long

#include <vector>

ll mx(ll a,ll b){
    if(a>b) return a;
    return b;
}

long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,std::vector<int> W) {
    ll dp[N][2],a[N];
    ll x1[N],x2[N];
    ll sum=0,say=0,sum0=0,sum1=0,say1=0;
    for(int i=0;i<N;i++){
        x1[i]=x2[i]=dp[i][0]=dp[i][1]=a[i]=0;
    }
    for(int i=0;i<M;i++){
        a[X[i]]=1ll*W[i];
        if(X[i]%2==1){
            say=1;
        }
        if(X[i]>1){
            say1=1;
        }
        if(X[i]==0){
            x1[Y[i]]=W[i];
            sum0+=W[i];
        }
        else{
            x2[Y[i]]=W[i];
            sum1+=W[i];
        }
        sum+=W[i];
    }
    ll SUM=mx(sum0,sum1);
    if(say1==0){
        for(int i=1;i<N;i++){
            x1[i]+=x1[i-1];
            x2[i]+=x2[i-1];
        }
        if(N>2){
            for(int i=0;i<N;i++){
                SUM=mx(SUM,x1[i]+x2[N-1]-x2[i]);
            }
        }
    }
    dp[0][1]=a[0];
    dp[1][0]=a[0];
    dp[1][1]=a[1];
    ll ans=mx(a[0],a[1]);
    for(int i=2;i<N;i++){
        if(i>2){
            dp[i][0]=mx(dp[i-3][0]+a[i-1]+a[i-2],mx(dp[i-1][1],dp[i-1][0]));
        }
        else{
            dp[i][0]=dp[i-1][1];
        }
        dp[i][1]=dp[i-1][0]+a[i];

    }
    ans=mx(dp[N-1][1],dp[N-1][0]);
    if(say==0){
        ans=sum;
    }
    else if(say1==0){
        ans=mx(sum0,sum1);
        if(N>2){
            ans=SUM;
        }
    }
    return ans;
}
/*
9 9
0 0 1
1 0 4
2 0 5
3 0 2
4 0 1
5 0 5
6 0 3
7 0 2
8 0 1
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 5604 KB Output is correct
2 Correct 30 ms 6476 KB Output is correct
3 Correct 3 ms 4180 KB Output is correct
4 Correct 3 ms 4180 KB Output is correct
5 Correct 87 ms 11232 KB Output is correct
6 Correct 89 ms 11216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 68 ms 7588 KB Output is correct
3 Correct 65 ms 12332 KB Output is correct
4 Correct 25 ms 7056 KB Output is correct
5 Correct 31 ms 8252 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
11 Correct 4 ms 4144 KB Output is correct
12 Correct 33 ms 7120 KB Output is correct
13 Correct 30 ms 8244 KB Output is correct
14 Correct 26 ms 7008 KB Output is correct
15 Correct 29 ms 7884 KB Output is correct
16 Correct 35 ms 7116 KB Output is correct
17 Correct 39 ms 7868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4180 KB Output is correct
2 Correct 3 ms 4180 KB Output is correct
3 Correct 16 ms 5076 KB Output is correct
4 Correct 11 ms 5076 KB Output is correct
5 Correct 30 ms 6472 KB Output is correct
6 Correct 22 ms 6472 KB Output is correct
7 Correct 28 ms 6468 KB Output is correct
8 Correct 30 ms 6472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4180 KB Output is correct
2 Correct 3 ms 4180 KB Output is correct
3 Correct 16 ms 5076 KB Output is correct
4 Correct 11 ms 5076 KB Output is correct
5 Correct 30 ms 6472 KB Output is correct
6 Correct 22 ms 6472 KB Output is correct
7 Correct 28 ms 6468 KB Output is correct
8 Correct 30 ms 6472 KB Output is correct
9 Incorrect 28 ms 6572 KB 1st lines differ - on the 1st token, expected: '99999', found: '66666'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 5604 KB Output is correct
2 Correct 30 ms 6476 KB Output is correct
3 Correct 3 ms 4180 KB Output is correct
4 Correct 3 ms 4180 KB Output is correct
5 Correct 87 ms 11232 KB Output is correct
6 Correct 89 ms 11216 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 68 ms 7588 KB Output is correct
9 Correct 65 ms 12332 KB Output is correct
10 Correct 25 ms 7056 KB Output is correct
11 Correct 31 ms 8252 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 3 ms 4180 KB Output is correct
17 Correct 4 ms 4144 KB Output is correct
18 Correct 33 ms 7120 KB Output is correct
19 Correct 30 ms 8244 KB Output is correct
20 Correct 26 ms 7008 KB Output is correct
21 Correct 29 ms 7884 KB Output is correct
22 Correct 35 ms 7116 KB Output is correct
23 Correct 39 ms 7868 KB Output is correct
24 Correct 3 ms 4180 KB Output is correct
25 Correct 3 ms 4180 KB Output is correct
26 Correct 16 ms 5076 KB Output is correct
27 Correct 11 ms 5076 KB Output is correct
28 Correct 30 ms 6472 KB Output is correct
29 Correct 22 ms 6472 KB Output is correct
30 Correct 28 ms 6468 KB Output is correct
31 Correct 30 ms 6472 KB Output is correct
32 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
33 Halted 0 ms 0 KB -