Submission #832725

# Submission time Handle Problem Language Result Execution time Memory
832725 2023-08-21T14:14:39 Z Jokubas Crosses on the Grid (FXCUP4_cross) C++17
63 / 100
1000 ms 30796 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((int)didziausi.size() <= 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;
            }

            /*int r = j;
            int l = min((int)didziausi.size(), K-1);

            while(r<l)
            {
                int m = (r+l)/2;
            }*/



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

        if(isviso < K)
        {
            kur = isviso;
            continue;
        }

        ll plotas = (ll)dabar*(2*(ll)didziausi[K-1] - (ll)dabar);

        ats = max(ats, plotas);


        kur = isviso;
    }


    return ats;
}
# Verdict Execution time Memory 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 1 ms 340 KB Output is correct
5 Correct 7 ms 1816 KB Output is correct
6 Correct 234 ms 26864 KB Output is correct
7 Correct 219 ms 26812 KB Output is correct
8 Correct 207 ms 26832 KB Output is correct
# Verdict Execution time Memory 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 1 ms 340 KB Output is correct
5 Correct 7 ms 1816 KB Output is correct
6 Correct 234 ms 26864 KB Output is correct
7 Correct 219 ms 26812 KB Output is correct
8 Correct 207 ms 26832 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 7 ms 1876 KB Output is correct
13 Correct 93 ms 13760 KB Output is correct
14 Correct 217 ms 26824 KB Output is correct
15 Correct 234 ms 26936 KB Output is correct
16 Correct 226 ms 26920 KB Output is correct
# Verdict Execution time Memory 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 1 ms 340 KB Output is correct
5 Correct 7 ms 1816 KB Output is correct
6 Correct 234 ms 26864 KB Output is correct
7 Correct 219 ms 26812 KB Output is correct
8 Correct 207 ms 26832 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 7 ms 1876 KB Output is correct
13 Correct 93 ms 13760 KB Output is correct
14 Correct 217 ms 26824 KB Output is correct
15 Correct 234 ms 26936 KB Output is correct
16 Correct 226 ms 26920 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 253 ms 2088 KB Output is correct
20 Correct 584 ms 13884 KB Output is correct
21 Correct 144 ms 24344 KB Output is correct
22 Correct 241 ms 30768 KB Output is correct
23 Correct 251 ms 30784 KB Output is correct
24 Execution timed out 1080 ms 30796 KB Time limit exceeded
25 Halted 0 ms 0 KB -