Submission #1060070

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
10600702024-08-15 10:27:13thangdz2k7Distributing Candies (IOI21_candies)C++17
100 / 100
210 ms41424 KiB
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, q;
vector <int> event[N];
long long sum[4 * N], Max[4 * N], Min[4 * N];
void upd(int u, int val, int s = 1, int l = 0, int r = q - 1){
if (l == r){
sum[s] = val;
Max[s] = max(0, val);
Min[s] = min(0, val);
return;
}
int mid = l + r >> 1;
if (mid >= u) upd(u, val, 2 * s, l, mid);
else upd(u, val, 2 * s + 1, mid + 1, r);
sum[s] = sum[2 * s] + sum[2 * s + 1];
Max[s] = max(Max[2 * s], sum[2 * s] + Max[2 * s + 1]);
Min[s] = min(Min[2 * s], sum[2 * s] + Min[2 * s + 1]);
}
long long get(int time, int s = 1, int l = 0, int r = q - 1){
if (l == r){
if (sum[s] < 0) return 0;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

candies.cpp: In function 'void upd(int, int, int, int, int)':
candies.cpp:19:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   19 |     int mid = l + r >> 1;
      |               ~~^~~
candies.cpp: In function 'long long int get(int, int, int, int)':
candies.cpp:35:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   35 |     int mid = l + r >> 1;
      |               ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...