Submission #1307996

#TimeUsernameProblemLanguageResultExecution timeMemory
1307996dimitris71Art Exhibition (JOI18_art)C++20
50 / 100
1096 ms8644 KiB
#include <cstdio>
#include <algorithm> 
#include <vector> 
#include <utility>
using namespace std; 

vector < pair < long long, long long > > X;

int main() {
    int N; long long res = 0;
    scanf("%d", &N);

    for (int i=0; i<N; i++) {
        long long a, b;
        scanf("%lld%lld", &a, &b);
        X.push_back(make_pair(a, b));
    }
    sort(X.begin(), X.end());
    
    for (int i=0; i<N; i++) {
        long long sum = 0;
        for (int j=i; j<N; j++) {
            sum += X[j].second; 
            res = max(res, sum - (X[j].first - X[i].first));
        } 
    }
    printf("%lld\n", res);

}

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d", &N);
      |     ~~~~~^~~~~~~~~~
art.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%lld%lld", &a, &b);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...