Submission #959719

# Submission time Handle Problem Language Result Execution time Memory
959719 2024-04-08T23:17:05 Z vjudge1 Art Exhibition (JOI18_art) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

const long long oo = 1e18 + 7;

void opt()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
}

struct Artwork
{
    bool operator< (Artwork otro) const
    {
        return size < otro.size;
    }

    long long 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);

    long long sumAc[n];
    long long aux = 0;

    for (int i = 0; i < n; i++)
    {
        aux += candidates[i].value;
        sumAc[i] = aux;
    }

    long long maxR = -oo;

    for (int i = 0; i < n - 1; i++)
    {
        int ini = i;

        for (int j =  ini + 1; j < n; j++)
        {
            int fin = j;

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