Submission #148968

# Submission time Handle Problem Language Result Execution time Memory
148968 2019-09-01T05:28:51 Z JeffreyHo(#3776, JeffreyHo) Crosses on the Grid (FXCUP4_cross) C++17
8 / 100
141 ms 5228 KB
#include "cross.h"
#include <bits/stdc++.h>
using namespace std;

long long SelectCross(int k, std::vector<int> a, std::vector<int> b) {
	int n = (int)a.size();
    pair<int, int> c[200005] = {};
    for (int i = 0; i < n; i++) c[i] = {b[i], b[i] - a[i]};
    sort(c, c + n); reverse(c, c + n);
    multiset<int> s;
    for (int i = 0; i < k; i++) s.insert(c[i].second);
    long long z = 1ll * c[k - 1].first * c[k - 1].first - 1ll * *s.rbegin() * *s.rbegin();
    for (int i = k; i < n; i++) {
        s.insert(c[i].second);
        s.erase(s.find(*s.rbegin()));
        z = max(z, 1ll * c[i].first * c[i].first - 1ll * *s.rbegin() * *s.rbegin());
    }
	return z;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1920 KB Output is correct
2 Correct 6 ms 1920 KB Output is correct
3 Correct 6 ms 1920 KB Output is correct
4 Correct 8 ms 1920 KB Output is correct
5 Correct 13 ms 2172 KB Output is correct
6 Correct 141 ms 5224 KB Output is correct
7 Correct 123 ms 5096 KB Output is correct
8 Correct 123 ms 5228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1920 KB Output is correct
2 Correct 6 ms 1920 KB Output is correct
3 Correct 6 ms 1920 KB Output is correct
4 Correct 8 ms 1920 KB Output is correct
5 Correct 13 ms 2172 KB Output is correct
6 Correct 141 ms 5224 KB Output is correct
7 Correct 123 ms 5096 KB Output is correct
8 Correct 123 ms 5228 KB Output is correct
9 Incorrect 8 ms 1920 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1920 KB Output is correct
2 Correct 6 ms 1920 KB Output is correct
3 Correct 6 ms 1920 KB Output is correct
4 Correct 8 ms 1920 KB Output is correct
5 Correct 13 ms 2172 KB Output is correct
6 Correct 141 ms 5224 KB Output is correct
7 Correct 123 ms 5096 KB Output is correct
8 Correct 123 ms 5228 KB Output is correct
9 Incorrect 8 ms 1920 KB Output isn't correct
10 Halted 0 ms 0 KB -