제출 #582045

#제출 시각아이디문제언어결과실행 시간메모리
582045hibikiArt Exhibition (JOI18_art)C++11
100 / 100
946 ms63964 KiB
#include<bits/stdc++.h>
using namespace std;

#define pb push_back

int n;
long long a[500005],b[500005],sz[500005];
long long ans = 0, dp[500005];
vector<long long> az;
map<long long,int> mp;

int main()
{
    scanf("%d",&n);
    for(int i = 0; i < n; i++)
    {
        scanf("%lld %lld",&a[i],&b[i]);
        az.pb(a[i]);
    }
    unique(az.begin(), az.end());
    sort(az.begin(),az.end());
    for(int i = 0; i < az.size(); i++)
        mp[az[i]] = i;
    for(int i = 0; i < n; i++)
        sz[mp[a[i]]] += b[i];
    for(int i = 0; i < az.size(); i++)
    {
        dp[i] = sz[i];
        if(i)
            dp[i] += max(0ll, dp[i - 1] - (az[i] - az[i - 1]));
        ans = max(ans,dp[i]);
    }

    printf("%lld\n",ans);
}

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

art.cpp: In function 'int main()':
art.cpp:22:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(int i = 0; i < az.size(); i++)
      |                    ~~^~~~~~~~~~~
art.cpp:26:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i = 0; i < az.size(); i++)
      |                    ~~^~~~~~~~~~~
art.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
art.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%lld %lld",&a[i],&b[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...