Skip to content

Commit

Permalink
Add 05612.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiyabye committed Jan 31, 2024
1 parent 62d6f1b commit 5b81c0b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions 05xxx/05612.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <algorithm>
#include <iostream>
using namespace std;

int solve(void) {
int n; cin >> n;
int m; cin >> m;

int ans = m, cur = m;
for (int i=0; i<n; i++) {
int a, b; cin >> a >> b;
cur += a - b;
if (cur < 0) return 0;
ans = max(ans, cur);
}
return ans;
}

int main(void) {
ios::sync_with_stdio(false);
cin.tie(nullptr);

cout << solve();
return 0;
}

0 comments on commit 5b81c0b

Please sign in to comment.