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 <vector>
#include <iostream>
#include <queue>
using namespace std;
long long take_photos(int n, int m, int k, vector<int> r, vector<int> c) {
bool b = true;
for (int i = 0; i < n; i++)
{
if (r[i] != c[i]) b = false;
}
if (!b)
{
int res = 0;
for (int i = 0; i < n; i++)
{
if (r[i] < c[i]) swap(r[i], c[i]);
}
for (int i = 0; i < m; i++)
{
for (int j = 0; j < m; j++)
{
bool on = false;
for (int l = 0; l < n; l++)
{
if (i <= r[l] && i >= c[l] && j <= r[l] && j >= c[l]) {on = true; break;}
}
res += on;
}
}
return res;
}
else
{
priority_queue<int> pq;
for (int i = 0; i < n; i++)
{
pq.push(-1);
}
for (int i = 0; i < n - k; i++)
{
int i1 = -pq.top();
pq.pop();
int i2 = -pq.top();
pq.pop();
pq.push(i1 + i2);
}
int res = 0;
while (pq.size() > 0)
{
res += (pq.top() * pq.top());
pq.pop();
}
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... |