Submission #151716

# Submission time Handle Problem Language Result Execution time Memory
151716 2019-09-04T10:36:15 Z leduykhongngu Crosses on the Grid (FXCUP4_cross) C++17
0 / 100
2 ms 256 KB
#include <vector>
#include <map>
#include <algorithm>
#include <assert.h>
long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
    //i<o
    int n = I.size();
    std::vector< std::pair<int, int > > rectangles;
    for (int i = 0; i < n; ++i)  {
        rectangles.push_back({O[i], I[i]});
    }
    sort(rectangles.begin(), rectangles.end());
    //reverse(rectangles.begin(), rectangles.end());
    std::map< int, int > mymap;
    for (auto rec : rectangles) {
        ++mymap[rec.second];
    }
    int cnt = 0;
    auto it = mymap.begin();
    long long res = 0;
    int last = 0;
    for (auto rec : rectangles) {
        //delete rec
        --mymap[rec.second];
        if (rec.second <= last) --cnt;
        while (it != mymap.end() && cnt < K) {
            cnt += it -> second;
            last = it -> first;
            ++it;
        }
        if (cnt >= K) {
            int Long = rec.first, Short = last;
            assert(Long >= Short);
            res = std::max(res, 1ll * Long * Long - 1ll * (Long - Short) * (Long - Short));
        }
    }
    return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -