답안 #1075718

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1075718 2024-08-26T08:48:20 Z Sir_Ahmed_Imran 메기 농장 (IOI22_fish) C++17
44 / 100
75 ms 17564 KB
                            ///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define append push_back
#define add insert
#define nl '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define terminator main
int n,m;
vector<int> x,y,w;
ll dps(){
    ll hs[n+1][n+1];
    ll dp[n+1][n+1];
    ll dp2[n+1][n+1];
    for(int i=0;i<=n;i++)
        for(int j=0;j<=n;j++)
            hs[i][j]=dp[i][j]=dp2[i][j]=0;
    for(int i=1;i<=n;i++)
        dp[0][i]=dp2[0][i]=-1e17;
    for(int i=0;i<m;i++)
        hs[x[i]+1][y[i]+1]+=w[i];
    for(int i=1;i<=n;i++)
        for(int j=0;j<n;j++)
            hs[i][j+1]+=hs[i][j];
    for(int i=1;i<=n;i++){
        for(int j=0;j<=n;j++){
            for(int k=0;k<=n;k++){
                if(j<k){
                    dp[i][j]=max(dp[i][j],dp[i-1][k]+hs[i][k]-hs[i][j]);
                    dp2[i][k]=max(dp2[i][k],dp[i-1][k]+hs[i][k]-hs[i][j]);
                }
                else{
                    dp[i][j]=max(dp[i][j],dp2[i-1][k]+hs[i-1][j]-hs[i-1][k]);
                    dp2[i][j]=max(dp2[i][j],dp2[i-1][k]+hs[i-1][j]-hs[i-1][k]);
                }
            }
            dp2[i][j]=max(dp2[i][j],dp[i-1][j]+hs[i][j]);
        }
    }
    ll ans=0;
    for(int i=0;i<=n;i++)
        ans=max(ans,max(dp[n][i],dp2[n][i]));
    return ans;
}
ll xs(){
    ll hs[3][n+1];
    for(int i=0;i<3;i++)
        for(int j=0;j<=n;j++)
            hs[i][j]=0;
    for(int i=0;i<m;i++)
        hs[x[i]+1][y[i]+1]+=w[i];
    for(int i=1;i<3;i++)
        for(int j=0;j<n;j++)
            hs[i][j+1]+=hs[i][j];
    ll ans=0;
    for(int i=0;i<=n;i++)
        ans=max(ans,hs[1][i]+hs[2][n]-hs[2][i]);
    return ans;
}
ll ys(){
    ll a[n+1];
    ll dp[n+1];
    for(int i=0;i<=n;i++) 
        a[i]=dp[i]=0;
    for(int i=0;i<m;i++)
        a[x[i]+1]=w[i];
    dp[2]=max(a[1],a[2]);
    for(int i=3;i<=n;i++)
        dp[i]=max(dp[i-1],max(a[i-1]+dp[i-2],a[i]+a[i-2]+dp[i-3]));
    return dp[n];
}
ll max_weights(int N,int M,vector<int> X,vector<int> Y,vector<int> W){
    n=N;m=M;x=X;y=Y;w=W;
    if(n<301) return dps();
    int mx,my;
    ll o=0;
    for(int i=mx=my=0;i<m;i++){
        mx=max(mx,x[i]);
        my=max(my,y[i]);
        o+=w[i];
    }
    if(mx<2) return xs();
    if(!my) return ys();
    return o;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 6756 KB Output is correct
2 Correct 23 ms 7872 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 2 ms 2652 KB Output is correct
5 Correct 64 ms 17240 KB Output is correct
6 Correct 65 ms 17564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 35 ms 10836 KB Output is correct
3 Correct 42 ms 13140 KB Output is correct
4 Correct 18 ms 6628 KB Output is correct
5 Correct 21 ms 8040 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 440 KB Output is correct
10 Correct 2 ms 2652 KB Output is correct
11 Correct 2 ms 2652 KB Output is correct
12 Correct 15 ms 6736 KB Output is correct
13 Correct 22 ms 8020 KB Output is correct
14 Correct 19 ms 6748 KB Output is correct
15 Correct 20 ms 7384 KB Output is correct
16 Correct 16 ms 6748 KB Output is correct
17 Correct 20 ms 7416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2648 KB Output is correct
2 Correct 2 ms 1884 KB Output is correct
3 Incorrect 11 ms 4544 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '21049836049923'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 6 ms 860 KB Output is correct
10 Correct 38 ms 2652 KB Output is correct
11 Correct 9 ms 860 KB Output is correct
12 Correct 60 ms 2596 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 38 ms 2588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 6 ms 860 KB Output is correct
10 Correct 38 ms 2652 KB Output is correct
11 Correct 9 ms 860 KB Output is correct
12 Correct 60 ms 2596 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 38 ms 2588 KB Output is correct
15 Correct 54 ms 2396 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 45 ms 4808 KB Output is correct
18 Correct 55 ms 4696 KB Output is correct
19 Correct 47 ms 4696 KB Output is correct
20 Correct 56 ms 4700 KB Output is correct
21 Correct 52 ms 4700 KB Output is correct
22 Correct 63 ms 6984 KB Output is correct
23 Correct 75 ms 2996 KB Output is correct
24 Correct 46 ms 3928 KB Output is correct
25 Correct 44 ms 2396 KB Output is correct
26 Correct 42 ms 2904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 6 ms 860 KB Output is correct
10 Correct 38 ms 2652 KB Output is correct
11 Correct 9 ms 860 KB Output is correct
12 Correct 60 ms 2596 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 38 ms 2588 KB Output is correct
15 Correct 54 ms 2396 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 45 ms 4808 KB Output is correct
18 Correct 55 ms 4696 KB Output is correct
19 Correct 47 ms 4696 KB Output is correct
20 Correct 56 ms 4700 KB Output is correct
21 Correct 52 ms 4700 KB Output is correct
22 Correct 63 ms 6984 KB Output is correct
23 Correct 75 ms 2996 KB Output is correct
24 Correct 46 ms 3928 KB Output is correct
25 Correct 44 ms 2396 KB Output is correct
26 Correct 42 ms 2904 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Incorrect 42 ms 11768 KB 1st lines differ - on the 1st token, expected: '72142312796929', found: '107871302004498'
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2648 KB Output is correct
2 Correct 2 ms 1884 KB Output is correct
3 Incorrect 11 ms 4544 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '21049836049923'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 6756 KB Output is correct
2 Correct 23 ms 7872 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 2 ms 2652 KB Output is correct
5 Correct 64 ms 17240 KB Output is correct
6 Correct 65 ms 17564 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 35 ms 10836 KB Output is correct
9 Correct 42 ms 13140 KB Output is correct
10 Correct 18 ms 6628 KB Output is correct
11 Correct 21 ms 8040 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 440 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 2 ms 2652 KB Output is correct
18 Correct 15 ms 6736 KB Output is correct
19 Correct 22 ms 8020 KB Output is correct
20 Correct 19 ms 6748 KB Output is correct
21 Correct 20 ms 7384 KB Output is correct
22 Correct 16 ms 6748 KB Output is correct
23 Correct 20 ms 7416 KB Output is correct
24 Correct 2 ms 2648 KB Output is correct
25 Correct 2 ms 1884 KB Output is correct
26 Incorrect 11 ms 4544 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '21049836049923'
27 Halted 0 ms 0 KB -