답안 #724329

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
724329 2023-04-15T05:59:23 Z nihaddhuseynli 메기 농장 (IOI22_fish) C++17
12 / 100
89 ms 19464 KB
#include "fish.h"
#include <bits/stdc++.h>
#include <vector>
using namespace std;
typedef long long int ll;
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,std::vector<int> W) {
    ll ans =0;
    ll a[300005];
    ll flag=0,flag1=0;
    for(int i =0;i<M;i++)
    {
        if(X[i]%2==1)
        {
            flag=1;
        }
        if(Y[i]!=0)
        {
            flag1=1;
        }
        a[X[i]]+=W[i];
    }
    if(flag==0)
    {
        ans=0;
        for(int i =0;i<M;i++)
        {
            ans+=W[i];
        }
        return ans;
    }
    else if(flag1==0)
    {
        ans=0;
        ll dp[300005][2];
        memset(dp,0,sizeof(dp));
        dp[1][0]=a[1];
        dp[1][1]=a[0];
        for(int i =2;i<N;i++)
        {
            dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][0]);
            dp[i][1]=max({dp[i-2][0]+a[i-1],dp[i-1][1],dp[i-2][1]+a[i-1]});
        }
        ans=max(dp[N-1][0],dp[N-1][1]);
        return ans;
    }
    else
    {
        ans=0;
        ll b[2][300005];
        memset(b,0,sizeof(b));
        for(int i =0;i<M;i++){
            b[X[i]][Y[i]] += W[i];
        }
        for(int i =1;i<N-1;i++){
            b[0][i] += b[0][i - 1];
            b[1][i] += b[1][i - 1];
        }
        ans = max(b[0][N - 1], b[1][N - 1]);
        if(N == 2) return ans;
        for(int i =0;i<N;i++)
        {
            long long val = b[1][N - 1] - b[1][i];
            ans=max(ans, val + b[0][i]);
        }
        return ans;
    }

}
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 9164 KB Output is correct
2 Correct 29 ms 9684 KB Output is correct
3 Correct 3 ms 7252 KB Output is correct
4 Correct 3 ms 7252 KB Output is correct
5 Correct 83 ms 14320 KB Output is correct
6 Correct 89 ms 14284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 7252 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 7252 KB Output is correct
2 Correct 4 ms 7252 KB Output is correct
3 Correct 18 ms 8624 KB Output is correct
4 Correct 13 ms 8172 KB Output is correct
5 Correct 28 ms 9676 KB Output is correct
6 Correct 24 ms 9688 KB Output is correct
7 Correct 28 ms 9672 KB Output is correct
8 Correct 28 ms 9680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 10 ms 14676 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 10 ms 14676 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 10 ms 14676 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 7252 KB Output is correct
2 Correct 4 ms 7252 KB Output is correct
3 Correct 18 ms 8624 KB Output is correct
4 Correct 13 ms 8172 KB Output is correct
5 Correct 28 ms 9676 KB Output is correct
6 Correct 24 ms 9688 KB Output is correct
7 Correct 28 ms 9672 KB Output is correct
8 Correct 28 ms 9680 KB Output is correct
9 Runtime error 35 ms 19464 KB Execution killed with signal 7
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 9164 KB Output is correct
2 Correct 29 ms 9684 KB Output is correct
3 Correct 3 ms 7252 KB Output is correct
4 Correct 3 ms 7252 KB Output is correct
5 Correct 83 ms 14320 KB Output is correct
6 Correct 89 ms 14284 KB Output is correct
7 Incorrect 3 ms 7252 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
8 Halted 0 ms 0 KB -