Submission #987678

#TimeUsernameProblemLanguageResultExecution timeMemory
987678TsaganaArt Exhibition (JOI18_art)C++14
100 / 100
155 ms25032 KiB
#include<bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie(); #define all(x) x.begin(), x.end() #define int long long #define pq priority_queue #define lb lower_bound #define ub upper_bound #define pb push_back #define eb emplace_back #define F first #define S second using namespace std; void solve () { int n; cin >> n; pair<int, int> a[500001]; for (int i = 0; i < n; i++) cin >> a[i].F >> a[i].S; sort(a, a + n); int ans, dp[500001]; dp[0] = a[0].S; for (int i = 1; i < n; i++) { dp[i] = max(a[i].S, dp[i - 1] + a[i - 1].F + a[i].S - a[i].F); ans = max(ans, dp[i]); } cout << ans << '\n'; } signed main() {IOS solve(); return 0;}

Compilation message (stderr)

art.cpp: In function 'void solve()':
art.cpp:22:6: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   22 |  int ans, dp[500001]; dp[0] = a[0].S;
      |      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...