Submission #149523

# Submission time Handle Problem Language Result Execution time Memory
149523 2019-09-01T06:40:33 Z Weeeee(#3729, Alexa2001) Crosses on the Grid (FXCUP4_cross) C++17
0 / 100
5 ms 384 KB
#include "cross.h"
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

long long SelectCross(int K, std::vector<int> V, std::vector<int> L)
{
    int i, n = V.size();
    vector<int> ord;
    ll ans = 0;

    for(i=1; i<=n; ++i)
        ord.push_back(i);

    auto cmp1 = [&L] (int x, int y)
    {
        return L[x] < L[y];
    };

    sort(ord.begin(), ord.end(), cmp1);

    multiset<int> S;
    for(i=1; i<=K; ++i) S.insert(0);

    for(i=n-1; i>=0; --i)
    {
        int id = ord[i];
        S.insert(V[id]);

        while(S.size() > K) S.erase(S.begin());

        int val = *S.begin();

        ans = max(ans, (ll) L[id] * L[id] - (ll) (L[id] - val) * (L[id] - val));
    }

	return ans;
}

Compilation message

cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:31:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(S.size() > K) S.erase(S.begin());
               ~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -