답안 #1050285

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1050285 2024-08-09T08:32:38 Z vjudge1 Art Exhibition (JOI18_art) C++
0 / 100
0 ms 344 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++) {
        s += q[i].s;
        if (i > 0 && q[i].f == q[i - 1].f) {
            continue;
        } else {
            if (i > 0) {
                a.push_back(make_pair(q[i - 1].f, s));
            }
        }
    }
    a.push_back(make_pair(q[n - 1].f, s));
    long long m = 0;
    for (int i = 0; i < a.size(); i++) {
        long long r = 0;
        for (int j = i; j < a.size(); j++) {
            if (i - 1 < 0) s = a[j].s;
            else s = a[j].s - a[i - 1].s;
            //cout << s << endl;
            r = s - (a[j].f - a[i].f);
            m = max(m, r);
        }
        
    }
    cout << m << endl;

    return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:30: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]
   30 |     for (int i = 0; i < a.size(); i++) {
      |                     ~~^~~~~~~~~~
art.cpp:32:27: 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]
   32 |         for (int j = i; j < a.size(); j++) {
      |                         ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -