답안 #773941

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
773941 2023-07-05T09:47:37 Z jasmin 메기 농장 (IOI22_fish) C++17
9 / 100
77 ms 12552 KB
#include "fish.h"
using namespace std;
#include<bits/stdc++.h>


long long subtask1(int N, int M, std::vector<int> X, std::vector<int> Y,
                      std::vector<int> W){

    long long ans=0;
    for(int i=0; i<M; i++){
        ans+=W[i];
    }
    return ans;
}
long long subtask2(int N, int M, std::vector<int> X, std::vector<int> Y,
                      std::vector<int> W){
    
    vector<pair<int,int>> c0;
    vector<pair<int,int>> c1;
    long long sum0=0;
    long long sum1=0;
    for(int i=0; i<M; i++){

        if(X[i]==0){
            c0.push_back({Y[i], W[i]});
            sum0+=W[i];
        }
        else{
            c1.push_back({Y[i], W[i]});
            sum1+=W[i];
        }

    }
    
    if(N==2){
        return max(sum0, sum1);
    }

    sort(c1.begin(), c1.end());
    sort(c0.begin(), c0.end());
    long long ans=max(sum0, sum1);
    long long mom=sum1;
    int j=0;
    for(int i=0; i<(int)c1.size(); i++){

        while(j<(int)c0.size() && c0[j].first<c1[i].first){

            mom+=c0[j].second;
            j++;

        }

        ans=max(ans, mom);

        mom-=c1[i].second;
    }
    return ans;
}

long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
                      std::vector<int> W) {

    if(N==1) return 0;

    bool sub1=true;
    bool sub2=true;
    for(int i=0; i<M; i++){

        if(X[i]%2==1){
            sub1=false;
        }
        if(X[i]>1){
            sub2=false;
        }

    }

    if(sub1){
        return subtask1(N, M, X, Y, W);
    }
    if(sub2){
        return subtask2(N, M, X, Y, W);
    }
}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:84:1: warning: control reaches end of non-void function [-Wreturn-type]
   84 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 3028 KB Output is correct
2 Correct 25 ms 3784 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 69 ms 10848 KB Output is correct
6 Correct 77 ms 10848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 49 ms 7612 KB Output is correct
3 Correct 62 ms 12552 KB Output is correct
4 Correct 18 ms 4444 KB Output is correct
5 Correct 23 ms 5556 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 300 KB Output is correct
11 Correct 0 ms 300 KB Output is correct
12 Correct 25 ms 5668 KB Output is correct
13 Correct 37 ms 6632 KB Output is correct
14 Correct 25 ms 5472 KB Output is correct
15 Correct 28 ms 6052 KB Output is correct
16 Correct 25 ms 5572 KB Output is correct
17 Correct 28 ms 5960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 17 ms 2792 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '26722445760742'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '310323004046'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '310323004046'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '310323004046'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 17 ms 2792 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '26722445760742'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 3028 KB Output is correct
2 Correct 25 ms 3784 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 69 ms 10848 KB Output is correct
6 Correct 77 ms 10848 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 49 ms 7612 KB Output is correct
9 Correct 62 ms 12552 KB Output is correct
10 Correct 18 ms 4444 KB Output is correct
11 Correct 23 ms 5556 KB Output is correct
12 Correct 0 ms 296 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 300 KB Output is correct
17 Correct 0 ms 300 KB Output is correct
18 Correct 25 ms 5668 KB Output is correct
19 Correct 37 ms 6632 KB Output is correct
20 Correct 25 ms 5472 KB Output is correct
21 Correct 28 ms 6052 KB Output is correct
22 Correct 25 ms 5572 KB Output is correct
23 Correct 28 ms 5960 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Incorrect 17 ms 2792 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '26722445760742'
27 Halted 0 ms 0 KB -