From 5b81c0bbb019c0f0e69797a72d27636ea0253e9d Mon Sep 17 00:00:00 2001 From: Hiyabye Date: Wed, 31 Jan 2024 14:45:54 +0900 Subject: [PATCH] Add 05612.cpp --- 05xxx/05612.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 05xxx/05612.cpp diff --git a/05xxx/05612.cpp b/05xxx/05612.cpp new file mode 100644 index 00000000..1673e3fe --- /dev/null +++ b/05xxx/05612.cpp @@ -0,0 +1,25 @@ +#include +#include +using namespace std; + +int solve(void) { + int n; cin >> n; + int m; cin >> m; + + int ans = m, cur = m; + for (int i=0; i> 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; +} \ No newline at end of file