Submission #968484

# Submission time Handle Problem Language Result Execution time Memory
968484 2024-04-23T13:24:12 Z tset Art Exhibition (JOI18_art) C++14
0 / 100
0 ms 348 KB
#include<bits/stdc++.h>

using namespace std;

#define int long long

const int INF = 1e18 +42;

signed main()
{
    int N;
    scanf("%lld", &N);
    vector<pair<int, int>> tab;
    for(int iTab = 0; iTab < N; iTab++)
    {
        int A, B;
        scanf("%lld%lld", &A, &B);
        tab.push_back({A, B});
    }
    sort(tab.begin(), tab.end());

    vector<int> cumulS(N, 0);
    cumulS[0] = tab[0].second;
    for(int i= 1; i<N; i++)
    {
        cumulS[i] = cumulS[i-1] + tab[i].second;
    }
    
    vector<int> SMalus(N);
    int valueMax = -INF;
    int idxMax = -INF;
    for(int i=0; i<N; i++)
    {
        SMalus[i] = cumulS[i] - tab[i].first;
        if(SMalus[i] >= valueMax)
        {
            valueMax = SMalus[i];
            idxMax = i;
        }
    }
    int ans = valueMax +tab[0].first;
    for(int i=1; i<= idxMax; i++)
    {
        ans = max(ans, valueMax - cumulS[i-1] + tab[i].first);
    }
    printf("%lld\n", ans);

}

Compilation message

art.cpp: In function 'int main()':
art.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%lld", &N);
      |     ~~~~~^~~~~~~~~~~~
art.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%lld%lld", &A, &B);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~
# 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 -