제출 #1335938

#제출 시각아이디문제언어결과실행 시간메모리
1335938enson메기 농장 (IOI22_fish)C++20
9 / 100
57 ms7260 KiB
#include <bits/stdc++.h>
using namespace std;

long long max_weights(int N, int M, vector<int>X, vector<int>Y, vector<int>W){
    bool st1 = true;
    for(int i = 0; i < M; i++) st1 &= (X[i]%2==0);
    bool st2 = true;
    for(int i = 0; i < M; i++) st2 &= (X[i]<=1);
    bool st3 = true;
    for(int i = 0; i < M; i++) st3 &= (Y[i]==0);
    if (st1){
        long long ans = 0;
        for(int i = 0; i < M; i++){
            ans += W[i];
        }
        return ans;
    }
    if (st2){
        long long ans = 0, c = 0, e = 0, o = 0;
        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>E, O;
        for(int i = 0; i < M; i++){
            if (X[i] == 0) E.push(make_pair(Y[i], i)), e += W[i];
            else O.push(make_pair(Y[i], i)), ans += W[i], c += W[i], o += W[i];
        }
        if (N == 2) return max(e, o);
        while (!E.empty()){
            pair<int, int> t = E.top();
            c += W[t.second];
            while (!O.empty() && (O.top().first) <= t.first){
                c -= W[O.top().second];
                O.pop();
            }
            E.pop();
            ans = max(ans, c);
        }
        return ans;
    }
    if (st3){
        long long A[M] = {0};
        A[0] = W[0];
        A[1] = W[1];
        for(int i = 2; i < M; i++){
            A[i] = max(A[i-2] + W[i], A[i-1]);
        }
        return max(A[M-1], A[M-2]);
    }
}

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

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:47:1: warning: control reaches end of non-void function [-Wreturn-type]
   47 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...