#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 |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |