제출 #1127475

#제출 시각아이디문제언어결과실행 시간메모리
1127475hy_1Art Exhibition (JOI18_art)C++17
100 / 100
168 ms8772 KiB
#include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <limits.h> #include <list> #include <cmath> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #include <unordered_map> using namespace std; #define int long long #define MOD 1000000007 #define INF 2000000000 #define IN 100001 #define LOG 20 #define MINF -2000000000 #define all(x) x.begin(),x.end() #define fast_io ios_base::sync_with_stdio(false);cin.tie(nullptr); void solution(){ int n; cin >> n; vector<pair<int, int> > arr; for(int i = 0; i < n; i++){ int a,b; cin >> a >> b; arr.push_back({a,b}); } sort(all(arr)); int cur = 0; int ans = 0; for(int i = 0; i < n; i++){ cur += arr[i].second; cur = max(cur , arr[i].first + arr[i].second); ans = max(ans , cur - arr[i].first); } cout << ans << endl; } signed main() { fast_io int t = 1; //cin >> t; while (t--) { solution(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...