| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1335462 | Bilolbek11 | Art Exhibition (JOI18_art) | C++20 | 0 ms | 344 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(s) s.begin(), s.end()
#define endl '\n'
#define ld long double
#define ull unsigned long long
#define vi vector<int>
#define vii vector<vector<int>>
#define vch vector<char>
#define ss second
#define ff first
#define vld vector<long double>
#define vs vector<string>
#define pb push_back
#define pp pop_back
#define pii pair<int, int>
#define vpp vector<pair<int, int>>
#define mp make_pair
#define sz(x) (int)x.size()
#define pi 3.14159265358979323846
string yes = "YES";
string no = "NO";
const int mod = 1e9 + 7;
const int mxN = 1e5 + 1;
const int inf = 1e18;
void setIO(string s)
{
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
void txt()
{
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
}
void solve()
{
int n;
cin >> n;
vpp a(n);
for (int i = 0;i < n;i++) {
cin >> a[i].ff >> a[i].ss;
}
sort(all(a));
vi pref(n + 1);
pref[0] = 0;
for (int i = 0;i < n;i++) {
pref[i + 1] += pref[i] + a[i].ss;
}
vi sm(n);
int ans = -inf;
int mn = inf;
for (int i = 0;i < n;i++) {
ans = max(ans, pref[i+1] - a[i].ff - mn);
mn = min(mn, pref[i] - a[i].ff);
}
cout << ans;
}
signed main()
{
// txt();
// setIO("problemname");
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
auto start = chrono::high_resolution_clock::now();
int t = 1;
//cin >> t;
while (t--)
{
solve();
// cout << endl;
}
#ifdef Bilol
auto duration = chrono::duration_cast<chrono::microseconds>(chrono::high_resolution_clock::now() - start);
cout << "Time: " << (double)duration.count() << " ms" << endl;
#endif
}
/*
██████╗░██╗██╗░░░░░░█████╗░██╗░░░░░██████╗░███████╗██╗░░██╗
██╔══██╗██║██║░░░░░██╔══██╗██║░░░░░██╔══██╗██╔════╝██║░██╔╝
██████╦╝██║██║░░░░░██║░░██║██║░░░░░██████╦╝█████╗░░█████═╝░
██╔══██╗██║██║░░░░░██║░░██║██║░░░░░██╔══██╗██╔══╝░░██╔═██╗░
██████╦╝██║███████╗╚█████╔╝███████╗██████╦╝███████╗██║░╚██╗
╚═════╝░╚═╝╚══════╝░╚════╝░╚══════╝╚═════╝░╚══════╝╚═╝░░╚═╝
*/컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
