Submission #151722

#TimeUsernameProblemLanguageResultExecution timeMemory
151722leduykhongnguCrosses on the Grid (FXCUP4_cross)C++17
8 / 100
300 ms14948 KiB
#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 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)); myset.erase(myset.find(rec.second)); if (myset.size() < K) break; } return res; }

Compilation message (stderr)

cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:27:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (myset.size() < K) break;
             ~~~~~~~~~~~~~^~~
cross.cpp:18:9: warning: unused variable 'cnt' [-Wunused-variable]
     int cnt = 0;
         ^~~
cross.cpp:20:9: warning: unused variable 'last' [-Wunused-variable]
     int last = 0;
         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...