이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define el '\n'
#define pb push_back
#define mp make_pair
#define niggers \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define file(name) \
freopen(name ".inp", "r", stdin); \
freopen(name ".out", "w", stdout);
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const int mxN = 1e2 + 5;
const int mxM = 1e3 + 5;
const int N = 5e5 + 5;
int hx[] = {-1, 0, 1, 0};
int hy[] = {0, 1, 0, -1};
ll pfs[N];
int main()
{
// freopen("b.inp", "r", stdin);
// freopen("b.out", "w", stdout);
ll pinkkiu = 1;
// cin >> pinkkiu;
while (pinkkiu--)
{
ll n;
cin >> n;
pll a[n + 5];
for (int i = 1; i <= n; ++i)
{
cin >> a[i].fi >> a[i].se;
}
ll ps[n + 5];
sort(a + 1, a + n + 1);
for (int i = 1; i <= n; ++i)
{
pfs[i] = pfs[i - 1] + a[i].se;
}
ll mn = inf;
ll ans = 0;
for (int i = 1; i <= n; i++)
{
mn = min(mn, pfs[i - 1] - a[i].fi);
ans = max(ans, pfs[i] - a[i].fi - mn);
}
cout << ans;
}
}
컴파일 시 표준 에러 (stderr) 메시지
art.cpp: In function 'int main()':
art.cpp:49:12: warning: unused variable 'ps' [-Wunused-variable]
49 | ll ps[n + 5];
| ^~| # | 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... |