답안 #832686

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
832686 2023-08-21T13:48:28 Z Jokubas 십자가 놓기 (FXCUP4_cross) C++17
0 / 100
1 ms 300 KB
#include <iostream>
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;

using namespace std;

ll SelectCross (int K, vector<int> I, vector<int> O)
{
    ll ats = 0;

    int N = I.size();

    map<int, vector<int>> lol;

    vector<pair<int, int>> visi;

    for(int i = 0; i<N; i++)
    {
        visi.pb({I[i], O[i]});

        lol[I[i]].pb(O[i]);
    }

    sort(visi.begin(), visi.end());
    reverse(visi.begin(), visi.end());

    int kiek = lol.size();

    int kur = 0;
    int isviso = 0;

    //vector<int> didziausi;
    deque<int> didziausi;

    for(int i = 0; i<kiek; i++)
    {
        int dabar = visi[kur].first;

        int kiekisI = lol[dabar].size();

        isviso += kiekisI;




        int k = 0;
        int j = 0;

        while(j < K && k < kiekisI)
        {
            if(didziausi.size() - 1 <= j)
            {
                didziausi.pb(visi[kur + k].second);
                j++; k++;
                continue;
            }

            if(visi[kur + k].second < didziausi[min((int)didziausi.size()-1, K-1)])
            {
                j = min((int)didziausi.size()-1, K-1) + 1;
                continue;
            }

            if(visi[kur + k].second > didziausi[j])
            {
                didziausi.insert(didziausi.begin() + j, visi[kur + k].second);
                k++;
            }
            j++;
        }




        ll plotas = (ll)dabar*(2*(ll)didziausi[min((int)didziausi.size()-1, K-1)] - (ll)dabar);

        ats = max(ats, plotas);

        kur = isviso;
    }


    return ats;
}

Compilation message

cross.cpp: In function 'll SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:52:37: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   52 |             if(didziausi.size() - 1 <= j)
      |                ~~~~~~~~~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 300 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 300 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 300 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -