Submission #528483

#TimeUsernameProblemLanguageResultExecution timeMemory
528483georgerapeanuArt Exhibition (JOI18_art)C++11
100 / 100
202 ms24828 KiB
#include <bits/stdc++.h>

using namespace std;

int main(){
  
  int n;

  scanf("%d", &n);

  vector<pair<long long, int> > v(n, {0, 0});
  vector<long long> dp(n, 0);

  for(auto &it:v){
    scanf("%lld %d", &it.first, &it.second);
  }

  sort(v.begin(), v.end());
  
  long long ans = 0;
  for(int i = 0;i < n;i++){
    dp[i] = max(1LL * v[i].second, (i == 0 ? 0LL:v[i].second - (v[i].first - v[i - 1].first) + dp[i - 1]));
    ans = max(ans, dp[i]);
  }
  printf("%lld\n", ans);

  return 0;
}

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:9:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
art.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%lld %d", &it.first, &it.second);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...