제출 #1260936

#제출 시각아이디문제언어결과실행 시간메모리
1260936rayan_bd메기 농장 (IOI22_fish)C++20
컴파일 에러
0 ms0 KiB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
long long dp[305][305][3], cost[305][305]; // 0 -> block, 1 -> take the single , 2 -> take two
vector<pair<int, int>> mp[305];
long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
  long long ans = 0;
  for(int i = 0; i < M; ++i){
    mp[X[i] + 1].push_back({Y[i] + 1, W[i]});
  }
  for(int i = 1; i <= N; ++i) sort(mp[i].begin(), mp[i].end());
  for(int i = 1; i <= N; ++i){
    int ptr = 0;
    for(int j = 1; j <= N; ++j){
        while(ptr < mp[i].size() && mp[i][ptr].first <= j){
            cost[i][j] += mp[i][ptr].second;
            ptr += 1;
        }
        cost[i][j] += cost[i][j - 1];
    }
  }
  for(int i = 1; i <= N; ++i){
    if(i >= 3){
        for(int j = 1; j <= N; ++j){
            for(int k = 1; k <= N; ++k){
                dp[i][j][2] = max(dp[i][j][2], dp[i - 2][k][0] + cost[i][j] + cost[i - 1][k]);
            }
        }
    }
    for(int j = 1; j <= N; ++j){
        for(int k = j; k <= N; ++k){
            dp[i][j][1] = max(dp[i][j][1], dp[i - 1][k][0] + cost[i][j]);
        }
        ans = max(dp[i][j][1], ans);
    }
    auto get = [&](int i, int l, int r) -> long long{
        if(l > r) return 0;
        return cost[i][r] - cost[i][l - 1];
    };
    for(int j = 1; j <= N; ++j){
        for(int k = 1; k <= j; ++k){
            dp[i][j][0] = max({dp[i - 1][k][0] + get(i - 1, k + 1, j), dp[i - 1][j][1], dp[i - 1][j][2]});
        }
        ans = max(ans, dp[i][j][0]);
    }
  }
  return ans;
}
signed main(){
    cout << max_weights(5, 4, {0, 1, 4, 3}, {2, 1, 4, 3}, {5, 2, 1, 3}) << endl;
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/ccf22eQn.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccADay3L.o:fish.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status