답안 #626819

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
626819 2022-08-11T21:03:40 Z ionan6ix 메기 농장 (IOI22_fish) C++17
3 / 100
81 ms 7252 KB
    #include "fish.h"

    #include <vector>
    #include<algorithm>
    using namespace std;

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

        bool flag = true;

        for(auto it:X)
            if(it%2)
            {
                flag = false;
                break;
            }

        if(flag)
        {
            long long sol = 0;
            for(auto it:W)
                sol+=it;

            return sol;
        }

        flag = true;

        for(auto it:X)
            if(it>1)
            {
                flag = false;
                break;
            }

        if(flag)
        {
            std::vector<pair<int,int> > y0;
            std::vector<pair<int,int> > y1;

            int sz = X.size();

            for(int i=0;i<sz;i++)
                if(X[i]==0) y0.emplace_back(Y[i],W[i]);
                    else y1.emplace_back(Y[i],W[i]);

            std::sort(y0.begin(),y0.end());
            std::sort(y1.begin(),y1.end());

            long long sol = 0LL;
            long long sum = 0LL;

            for(auto it:y1)
                sum += 1LL*it.second;

            sol = sum;

            /**
             * Pana la un anumit punct luam din 0, apoi din 1
             */

            int pnt0 = -1;
            int pnt1 = 0;
            long long sum0 = 0;
            for(int i=0;i<(int)y0.size();i++)
            {
                pnt0++;
                sum0 += 1LL * y0[pnt0].second;

                while(pnt1<(int)y1.size() && y1[pnt1].first<=y0[pnt0].first)
                {
                    sum -= 1LL * y1[pnt1].second;
                    pnt1++;
                }
                sol = max(sol,sum+sum0);
            }

            return sol;
        }
        return 0;
    }
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 2128 KB Output is correct
2 Correct 26 ms 2612 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 80 ms 7248 KB Output is correct
6 Correct 81 ms 7252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 59 ms 5684 KB Output is correct
3 Correct 67 ms 6712 KB Output is correct
4 Correct 21 ms 2140 KB Output is correct
5 Correct 26 ms 2624 KB Output is correct
6 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '4044', found: '6066'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '882019', found: '0'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '882019', found: '0'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 2128 KB Output is correct
2 Correct 26 ms 2612 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 80 ms 7248 KB Output is correct
6 Correct 81 ms 7252 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 59 ms 5684 KB Output is correct
9 Correct 67 ms 6712 KB Output is correct
10 Correct 21 ms 2140 KB Output is correct
11 Correct 26 ms 2624 KB Output is correct
12 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '4044', found: '6066'
13 Halted 0 ms 0 KB -