답안 #1115297

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1115297 2024-11-20T10:06:34 Z staszic_ojuz Art Exhibition (JOI18_art) C++17
0 / 100
1 ms 336 KB
#include<bits/stdc++.h>
using namespace std;
int main() {
    long long n, wiel, wart, l = 0, p = 0;
    cin >> n;
    map<long long, long long> m;
    vector<vector<long long>> v;
    for (int i = 0; i < n; i++) {
        cin >> wiel >> wart;
        m[wiel] += wart;
    }
    for (auto [wie, war] : m) {
        v.push_back({wie, war});
    }
    long long wyn = 0, suma = v[0][1];
    while (l < v.size()) {
        if (p < v.size() && suma - v[p][0] + v[l][0] > 0) {
            if (suma - v[p][0] + v[l][0] > wyn) {
                wyn = suma - v[p][0] + v[l][0];
            }
            p += 1;
            if (p < v.size() - 1) {
                suma += v[p][1];
            }
        }
        else {
            suma -= v[l][1];
            l += 1;
        }
    }
    cout << max(wyn, v[v.size() - 1][1]);
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:16:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     while (l < v.size()) {
      |            ~~^~~~~~~~~~
art.cpp:17:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         if (p < v.size() && suma - v[p][0] + v[l][0] > 0) {
      |             ~~^~~~~~~~~~
art.cpp:22:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             if (p < v.size() - 1) {
      |                 ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -