답안 #626003

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
626003 2022-08-11T06:13:59 Z aryan12 메기 농장 (IOI22_fish) C++17
6 / 100
131 ms 13556 KB
#include "fish.h"

#include <bits/stdc++.h>
using namespace std;

// subtask 2

bool cmp(array<int, 3> a, array<int, 3> b)
{
    if(a[1] != b[1]) return a[1] < b[1];
    return a[0] > b[0];
}

long long max_weights(int N, int M, std::vector<int> X, 
    std::vector<int> Y, std::vector<int> W) {
    long long ans1 = 0, ans2 = 0;
    for(int i = 0; i < W.size(); i++)
    {
        if(X[i] == 0) ans1 += W[i];
        else ans2 += W[i];
    }
    if(N == 2)
    {
        return max(ans1, ans2);
    }
    vector<array<int, 3> > vect;
    for(int i = 0; i < W.size(); i++)
    {
        vect.push_back({X[i], Y[i], W[i]});
    }
    sort(vect.begin(), vect.end(), cmp);
    long long cur_ans = max(ans1, ans2);
    ans1 = 0;
    for(int i = 0; i < vect.size(); i++)
    {
        if(vect[i][0] == 0)
        {
            ans1 += vect[i][2];
        }
        else
        {
            ans2 -= vect[i][2];
        }
        cur_ans = max(cur_ans, ans1 + ans2);
    }
    return cur_ans;
}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:17:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i = 0; i < W.size(); i++)
      |                    ~~^~~~~~~~~~
fish.cpp:27:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i = 0; i < W.size(); i++)
      |                    ~~^~~~~~~~~~
fish.cpp:34:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for(int i = 0; i < vect.size(); i++)
      |                    ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 3788 KB Output is correct
2 Correct 40 ms 4284 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 128 ms 13520 KB Output is correct
6 Incorrect 131 ms 13556 KB 1st lines differ - on the 1st token, expected: '300000000000000', found: '299997000000000'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 68 ms 7316 KB Output is correct
3 Correct 90 ms 8132 KB Output is correct
4 Correct 32 ms 3812 KB Output is correct
5 Correct 39 ms 4284 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 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 38 ms 3816 KB Output is correct
13 Correct 40 ms 4292 KB Output is correct
14 Correct 32 ms 3788 KB Output is correct
15 Correct 38 ms 4040 KB Output is correct
16 Correct 33 ms 3788 KB Output is correct
17 Correct 36 ms 4032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 21 ms 2476 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 1 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 1 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 1 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 1 ms 212 KB Output is correct
3 Incorrect 21 ms 2476 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '26722445760742'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 3788 KB Output is correct
2 Correct 40 ms 4284 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 128 ms 13520 KB Output is correct
6 Incorrect 131 ms 13556 KB 1st lines differ - on the 1st token, expected: '300000000000000', found: '299997000000000'
7 Halted 0 ms 0 KB -