| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 151721 | leduykhongngu | Crosses on the Grid (FXCUP4_cross) | C++17 | 2 ms | 256 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <vector>
#include <set>
#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::multiset< int > myset;
    for (auto rec : rectangles) {
        myset.insert(rec.second);
    }
    int cnt = 0;
    long long res = 0;
    int last = 0;
    for (auto rec : rectangles) {
        //delete rec
        myset.erase(myset.find(rec.second));
        if (myset.size() < K) break;
        int Long = rec.first, Short = (K == 1? rec.second : *myset.begin());
        assert(Long >= Short);
        res = std::max(res, 1ll * Long * Long - 1ll * (Long - Short) * (Long - Short));
    }
    return res;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
