Submission #852376

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
8523762023-09-21 16:38:54vjudge1Holiday (IOI14_holiday)C++17
100 / 100
265 ms15000 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#include "holiday.h"
using namespace std;
pair<int, int> a[400005];
long long f[400005], g[400005], res = 0;
int d;
struct DAY {
long long int res, c;
};
DAY t[1600005];
void update(int v, int x) {
v += 400005;
if (x < 0) t[v].c = 0;
else t[v].c = 1;
t[v].res += x;
v /= 2;
while (v > 0) {
t[v].c = t[v * 2].c + t[v * 2 + 1].c;
t[v].res = t[v * 2].res + t[v * 2 + 1].res;
v /= 2;
}
}
long long int sum(int v, int l, int r, int x) {
if (t[v].c == 0 || x <= 0) return 0;
if (t[v].c <= x) return t[v].res;
int mid = (l + r) / 2;
if (t[v * 2 + 1].c >= x) return sum(v * 2 + 1, mid + 1, r, x);
return t[v * 2 + 1].res + sum(v * 2, l, mid, x - t[v * 2 + 1].c);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
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...