이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int oo = 1e9 + 7;
void opt()
{
ios_base :: sync_with_stdio(false);
cin.tie(nullptr);
}
struct Artwork
{
bool operator< (Artwork otro) const
{
return size < otro.size;
}
int size, value;
};
int main()
{
opt();
int n; cin>>n;
Artwork candidates[n];
for (int i = 0; i < n; i++)
{
cin>>candidates[i].size>>candidates[i].value;
}
sort(candidates, candidates + n);
int sumAc[n];
int aux = 0;
for (int i = 0; i < n; i++)
{
aux += candidates[i].value;
sumAc[i] = aux;
}
int maxR = -oo;
for (int i = 0; i < n - 1; i++)
{
int ini = i;
for (int j = ini + 1; j < n; j++)
{
int fin = j;
int cost;
if (i == 0)
{
cost = sumAc[j];
}else
{
cost = sumAc[j] - sumAc[ini - 1];
}
cost -= (candidates[fin].size - candidates[ini].size);
maxR = max(maxR, cost);
}
}
cout<<maxR<<"\n";
}
# | 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... |