답안 #1079281

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1079281 2024-08-28T12:38:07 Z vjudge1 메기 농장 (IOI22_fish) C++17
9 / 100
63 ms 10976 KB
#include "fish.h"

#include <bits/stdc++.h>

#define fore(i, l, r) for(int i=int(l); i<int(r); i++)

using namespace std;

long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
                      std::vector<int> W) {
  long long ok=1,ok1=1;
    fore(i,0,M) {
        if(X[i] % 2)
            ok=0;
        if(X[i] > 1)
            ok1=0;
    }
    long long ans=0;
    if(ok)
      fore(i,0,M)
        ans+=W[i];
    else if(ok1) {
      long long grid[2][N+5];
      memset(grid,0,sizeof grid);
      fore(i,0,M)
        grid[X[i]][Y[i]] = W[i];
      long long sum1=0,sum2=0,temp1=0,temp2=0;
      if(N > 2) {
        fore(i,0,N) {
          sum1+=grid[0][i];
          sum2+=grid[1][i];
          if(sum1 >= sum2 and abs(sum1-sum2) >= abs(temp1-temp2)) {
            temp1=sum1;
            temp2=sum2;
          }
        }
        ans = sum2-temp2+temp1;
      } else {
        fore(i,0,N) {
          sum1+=grid[0][i];
          sum2+=grid[1][i];
        }
        return max(sum1,sum2);
      }
    } else {
      long long grid[N+5];
      memset(grid,0,sizeof grid);
      fore(i,0,M)
        grid[X[i]] = W[i];
      long long dp[N+5];
      memset(dp,0,sizeof dp);
      fore(i,0,N) {
        dp[i] = grid[i+1];
        if(i)
          dp[i] += grid[i-1];
        if(i>1)
          dp[i] += dp[i-2];
        if(i)
          dp[i] = max(dp[i-1],dp[i]);
      }
      ans = dp[N-1];
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 3164 KB Output is correct
2 Correct 19 ms 3664 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 56 ms 10580 KB Output is correct
6 Correct 63 ms 10976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 31 ms 6976 KB Output is correct
3 Correct 37 ms 8728 KB Output is correct
4 Correct 14 ms 3316 KB Output is correct
5 Correct 17 ms 3672 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 436 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 30 ms 4724 KB Output is correct
13 Correct 24 ms 5388 KB Output is correct
14 Correct 18 ms 4548 KB Output is correct
15 Correct 18 ms 5080 KB Output is correct
16 Correct 17 ms 4660 KB Output is correct
17 Correct 19 ms 4948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 1884 KB Output is correct
3 Incorrect 13 ms 3676 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '31413834858038'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 432 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 412 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 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 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '84248892991'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 432 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 412 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 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 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '84248892991'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 432 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 412 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 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 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '84248892991'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 1884 KB Output is correct
3 Incorrect 13 ms 3676 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '31413834858038'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 3164 KB Output is correct
2 Correct 19 ms 3664 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 56 ms 10580 KB Output is correct
6 Correct 63 ms 10976 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 31 ms 6976 KB Output is correct
9 Correct 37 ms 8728 KB Output is correct
10 Correct 14 ms 3316 KB Output is correct
11 Correct 17 ms 3672 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 436 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 30 ms 4724 KB Output is correct
19 Correct 24 ms 5388 KB Output is correct
20 Correct 18 ms 4548 KB Output is correct
21 Correct 18 ms 5080 KB Output is correct
22 Correct 17 ms 4660 KB Output is correct
23 Correct 19 ms 4948 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 1884 KB Output is correct
26 Incorrect 13 ms 3676 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '31413834858038'
27 Halted 0 ms 0 KB -