Submission #149131

#TimeUsernameProblemLanguageResultExecution timeMemory
149131샌즈뼈 (#200)Crosses on the Grid (FXCUP4_cross)C++17
63 / 100
140 ms6500 KiB
#include "cross.h" #include <bits/stdc++.h> using namespace std; long long SelectCross(int K, std::vector<int> I, std::vector<int> O) { int N = I.size(); vector<pair<int, int>> v; for(int i=0; i<N; i++) v.emplace_back(I[i], O[i]); sort(v.rbegin(), v.rend()); //for(int i=0;i <N; i++) cout << v[i].first << ' '; cout << endl; //for(int i=0;i <N; i++) cout << v[i].second << ' '; cout << endl; set<int> s; for(int i=0; i<K-1; i++) { s.insert(v[i].second); } long long res = 0; for(int i=K-1; i<N; i++) { if(s.size()+1 > K) s.erase(s.begin()); s.insert(v[i].second); int ii = v[i].first; int oo = *(s.begin()); //cout <<r << ' ' << t << endl; res = max(res, 1LL*oo*oo - 1LL*(oo-ii)*(oo-ii)); } return res; }

Compilation message (stderr)

cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:24:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(s.size()+1 > K) s.erase(s.begin());
        ~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...