답안 #850835

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
850835 2023-09-17T13:41:34 Z AliHasanli 메기 농장 (IOI22_fish) C++17
3 / 100
179 ms 20816 KB
#include <iostream>
#include <vector>
#include<map>
using namespace std;
map<int,int>mX,mY;
long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W)
{
    for(int i=0;i<X.size();i++)
    {
        mX[X[i]]=1;
        mY[Y[i]]=1;
    }
    if(N==1)
        return 0;
    bool check=true;
    int maxX=0;
    for(int i:X)
        maxX=max(maxX,i);
    for(int i:X)
        if(i%2)
        {
            check=false;
            break;
        }
    long long ans=0;
    if(check)
    {
        for(int i=0;i<W.size();i++)
        ans+=W[i];
        return ans;
    }
    if(maxX==0)
    {
        for(int i=0;i<W.size();i++)
            ans+=W[i];
        return ans;
    }
    if(maxX==1)
    {
        long long ansX0=0,ansX1=0,ans=0;
        for(int i=0;i<X.size();i++)
            if(X[i]==1)
                ansX1+=W[i];
        ans=ansX1;
        for(int i=0;i<N;i++)
        {
            if(mY[i]==1 && mX[1]==1)
            ansX1-=W[i];
            if(mY[i]==1 && mX[0]==1)
            ansX0+=W[i];
            ans=max(ans,ansX0+ansX1);
        }
        return ans;
    }
    return 0;
}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:8:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for(int i=0;i<X.size();i++)
      |                 ~^~~~~~~~~
fish.cpp:28:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for(int i=0;i<W.size();i++)
      |                     ~^~~~~~~~~
fish.cpp:34:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         for(int i=0;i<W.size();i++)
      |                     ~^~~~~~~~~
fish.cpp:41:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         for(int i=0;i<X.size();i++)
      |                     ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 7504 KB Output is correct
2 Correct 48 ms 9092 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 130 ms 18512 KB Output is correct
6 Correct 179 ms 20816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '882019', found: '0'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '882019', found: '0'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 7504 KB Output is correct
2 Correct 48 ms 9092 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 130 ms 18512 KB Output is correct
6 Correct 179 ms 20816 KB Output is correct
7 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
8 Halted 0 ms 0 KB -