Submission #223563

# Submission time Handle Problem Language Result Execution time Memory
223563 2020-04-15T12:47:53 Z Ruxandra985 Art Exhibition (JOI18_art) C++14
0 / 100
5 ms 384 KB
#include <bits/stdc++.h>

using namespace std;
pair <long long , long long> v[500010];
int main()
{
    FILE *fin = stdin;
    FILE *fout = stdout;
    int n , i;
    long long curr , sol;
    fscanf (fin,"%d",&n);
    for (i = 1 ; i <= n ; i++){
        fscanf (fin,"%lld%lld",&v[i].first,&v[i].second);
    }

    sort (v + 1 , v + n + 1);

    curr = sol = 0;

    for (i = 1 ; i <= n ; i++){
        if (curr + v[i].first - v[i + 1].first >= v[i].first - v[i + 1].first){
            curr += v[i].first - v[i + 1].first + v[i].second;
            if (i + 1 <= n)
                sol = max(sol , curr + v[i + 1].second);
        }
        else curr = v[i].first - v[i + 1].first + v[i].second;

        sol = max(sol , v[i].second);
    }

    fprintf (fout,"%lld",sol);

    return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:11:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf (fin,"%d",&n);
     ~~~~~~~^~~~~~~~~~~~~
art.cpp:13:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         fscanf (fin,"%lld%lld",&v[i].first,&v[i].second);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -