제출 #573110

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
5731102022-06-05 20:49:07colossal_pepeArt Exhibition (JOI18_art)C++17
100 / 100
433 ms54236 KiB
#include <iostream>
#include <algorithm>
#include <numeric>
#include <map>
using namespace std;
using ll = long long;
const int MAXN = 5e5 + 5;
int n;
ll a[MAXN], b[MAXN];
ll solve() {
int p[n];
iota(p, p + n, 0);
sort(p, p + n, [](int i, int j) {
return a[i] < a[j];
});
ll pfx_sum = 0, loss = 0;
map<ll, ll> m;
ll ans = 0;
for (int i = 0; i < n; i++) {
if (i == 0 or a[p[i]] != a[p[i - 1]]) {
m[a[p[i]]] = a[p[i]] - pfx_sum;
loss = max(loss, m[a[p[i]]]);
}
pfx_sum += b[p[i]];
ans = max(ans, pfx_sum + loss - a[p[i]]);
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...