Submission #136265

#TimeUsernameProblemLanguageResultExecution timeMemory
136265KLPPArt Exhibition (JOI18_art)C++14
100 / 100
278 ms24684 KiB
#include<bits/stdc++.h> using namespace std; typedef long long int lld; typedef pair<lld,lld> pii; #define rep(i,a,b) for(int i=a;i<b;i++) int main(){ int n; scanf("%d",&n); pii arr[n]; rep(i,0,n){ scanf("%lld %lld",&arr[i].first,&arr[i].second); } sort(arr,arr+n); lld DP[n]; DP[0]=arr[0].second; rep(i,1,n){ DP[i]=arr[i].second; DP[i]=max(DP[i],DP[i-1]+arr[i].second-(arr[i].first-arr[i-1].first)); } lld ans=0; rep(i,0,n)ans=max(ans,DP[i]); printf("%lld\n",ans); return 0; }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&n);
   ~~~~~^~~~~~~~~
art.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld",&arr[i].first,&arr[i].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...