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 "aliens.h"
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define vi vector<int>
#define ll long long
using namespace std;
long long take_photos(int n, int m, int k,vi r,vi c){
set<pair<ll,ll> >st;
for(int i=0;i<n;i++){
st.insert({r[i],r[i]});
}
n=st.size();
for(int i=0;i<n-k;i++){
ll mi=1e18;
ll ant=-100000;
set<pair<ll,ll> > :: iterator A,B,curr;
curr=st.begin();
for(auto it : st){
if(it.S-ant+1<mi){
A=curr;
B=st.find(it);
mi=it.S-ant+1;
}
ant=it.F;
curr=st.find(it);
}
ll be=(*A).F;
ll en=(*B).S;
st.erase(A);st.erase(B);
st.insert({be,en});
}
ll res=0;
for(auto it : st){
ll tam=it.S-it.F+1;
res+=tam*tam;
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |