제출 #757615

#제출 시각아이디문제언어결과실행 시간메모리
757615salmonArt Exhibition (JOI18_art)C++14
100 / 100
232 ms33124 KiB
#include <bits/stdc++.h>
using namespace std;

int N;
vector<pair<long long int, long long int>> v;

int main(){
    scanf(" %d",&N);

    for(int i = 0; i < N; i++){
        long long int A,B;

        scanf(" %lld",&A);
        scanf(" %lld",&B);

        v.push_back(make_pair(A,B));
    }

    sort(v.begin(),v.end());

    int it = 0;
    long long int ans = 0;
    long long int va = 0;
    vector<pair<long long int, long long int>> ve;
    ve.push_back(v[0]);

    for(int i = 1; i < N; i++){
        if(ve[it].first == v[i].first){
            ve[it].second += v[i].second;
        }
        else{
            ve.push_back(v[i]);
            it++;
        }
    }

    va = ve[0].second;
    ans = va;

    for(int i = 1; i < ve.size(); i++){
        va -= ve[i].first - ve[i - 1].first;
        if(va <= 0) va = 0;
        va += ve[i].second;
        ans = max(ans,va);
    }

    printf("%lld",ans);



}

컴파일 시 표준 에러 (stderr) 메시지

art.cpp: In function 'int main()':
art.cpp:40:22: 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]
   40 |     for(int i = 1; i < ve.size(); i++){
      |                    ~~^~~~~~~~~~~
art.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf(" %d",&N);
      |     ~~~~~^~~~~~~~~~
art.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf(" %lld",&A);
      |         ~~~~~^~~~~~~~~~~~
art.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf(" %lld",&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...