제출 #582046

#제출 시각아이디문제언어결과실행 시간메모리
582046hibikiArt Exhibition (JOI18_art)C++11
100 / 100
253 ms14188 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back int n; long long a[500005],b[500005]; long long ans = 0, dp[500005]; vector<int> v; int main() { scanf("%d",&n); for(int i = 0; i < n; i++) { scanf("%lld %lld",&a[i],&b[i]); v.pb(i); } sort(v.begin(),v.end(), [&](const int x, const int y){ return a[x] < a[y]; }); for(int i = 0; i < n; i++) { dp[i] = b[v[i]]; if(i) dp[i] += max(0ll, dp[i - 1] - (a[v[i]] - a[v[i - 1]])); ans = max(ans,dp[i]); } printf("%lld\n",ans); }

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

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