답안 #832640

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
832640 2023-08-21T12:52:41 Z Jokubas 십자가 놓기 (FXCUP4_cross) C++17
63 / 100
1000 ms 30736 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;
    //int didziausias = 0;
    for(int i = 0; i<N; i++)
    {
        visi.pb({I[i], O[i]});

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

        //didziausias = max(didziausias, I[i]);
    }

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

    int kiek = lol.size();

    int kur = 0;
    int isviso = 0;

    vector<int> didziausi;

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


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

        isviso += kiekisI;


        if(isviso<K)
        {
            for(auto c : lol[dabar])
            {
                didziausi.pb(c);
            }

            kur = isviso;
            continue;
        }



        for(int j = 0; j<min(K, kiekisI); j++)
        {
            if(didziausi.size()>0)
            {
                if(visi[kur + j].second > didziausi[K-1])
                {
                    didziausi.pb(visi[kur + j].second);
                }
            } else
            {
                didziausi.pb(visi[kur + j].second);
            }


        }

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

        if(didziausi.size()>K)
            didziausi.erase(didziausi.begin() + K, didziausi.end());


        ll plotas = (ll)dabar*(2*(ll)didziausi[didziausi.size()-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:79:28: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   79 |         if(didziausi.size()>K)
      |            ~~~~~~~~~~~~~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 252 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 8 ms 2132 KB Output is correct
6 Correct 229 ms 30672 KB Output is correct
7 Correct 244 ms 30728 KB Output is correct
8 Correct 208 ms 30696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 252 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 8 ms 2132 KB Output is correct
6 Correct 229 ms 30672 KB Output is correct
7 Correct 244 ms 30728 KB Output is correct
8 Correct 208 ms 30696 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 10 ms 2052 KB Output is correct
13 Correct 122 ms 15716 KB Output is correct
14 Correct 238 ms 30736 KB Output is correct
15 Correct 254 ms 30736 KB Output is correct
16 Correct 250 ms 30728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 252 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 8 ms 2132 KB Output is correct
6 Correct 229 ms 30672 KB Output is correct
7 Correct 244 ms 30728 KB Output is correct
8 Correct 208 ms 30696 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 10 ms 2052 KB Output is correct
13 Correct 122 ms 15716 KB Output is correct
14 Correct 238 ms 30736 KB Output is correct
15 Correct 254 ms 30736 KB Output is correct
16 Correct 250 ms 30728 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 4 ms 340 KB Output is correct
19 Correct 302 ms 2404 KB Output is correct
20 Execution timed out 1084 ms 15828 KB Time limit exceeded
21 Halted 0 ms 0 KB -