Submission #1050432

# Submission time Handle Problem Language Result Execution time Memory
1050432 2024-08-09T09:28:15 Z vjudge1 Art Exhibition (JOI18_art) C++
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;

int main() {
    long long n;
    cin >> n;
    pair<long long, long long> q[n];
    for (int i = 0; i < n; i++) {
        cin >> q[i].f >> q[i].s;
    }
    sort(q, q + n);

    vector<pair<long long, long long>> a;
    long long s = 0;
    for (int i = 0; i < n; i++) {
        if (i > 0 && q[i].f == q[i - 1].f) {
            s += q[i].s;
        } else {
            if (i > 0) {
                a.push_back(make_pair(q[i - 1].f, s));
            }
            s = q[i].s;
        }
    }
    a.push_back(make_pair(q[n - 1].f, s));
    
    long long m = LLONG_MIN;
    long long sum = 0;
    long long prefix_sum = 0;

    for (int i = 0; i < a.size(); i++) {
        prefix_sum += a[i].s;
        sum = prefix_sum - (a[i].f - a[0].f);
        m = max(m, sum);
    }

    cout << m << endl;
    return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:33:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for (int i = 0; i < a.size(); i++) {
      |                     ~~^~~~~~~~~~
# 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 -