Submission #1092573

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
10925732024-09-24 12:37:19SunbaeGrowing Trees (BOI11_grow)C++17
0 / 100
86 ms4180 KiB
#include <bits/stdc++.h>
#define z exit(0)
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;
pair<int,int> to_upd[2];
ll bit[N], a[N];
int n;
void upd(int i, ll v){ for(; i<=n; i+=i&-i) bit[i] += v;}
int qry(int i){ ll r = 0; for(; i; i-=i&-i) r += bit[i]; return r;}
void UPD(int l, int r){ upd(l, +1); upd(r+1, -1);}
ll A(int i){ return a[i] + qry(i);}
bool V(int i){ return 1 <= i && i <= n;}
signed main(){
int q; scanf("%d %d", &n, &q);
for(int i = 1; i<=n; ++i) scanf("%lld", a+i);
sort(a+1, a+1+n);
for(int i = 0, c, h, l, r, L, R, sz; i<q; ++i){
char op; scanf(" %c", &op);
if(op == 'F'){
scanf("%d %d", &c, &h);
int low = 1, high = n, st = n+1, ed = -1;
while(low <= high){
int mid = low + ((high-low)>>1);
if(A(mid) >= h) high = mid-1, st = mid;
else low = mid+1;
}
if(st > n) continue;
ed = min(n, st+c-1);
ll val = A(ed);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

grow.cpp: In function 'int main()':
grow.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |  int q; scanf("%d %d", &n, &q);
      |         ~~~~~^~~~~~~~~~~~~~~~~
grow.cpp:16:33: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  for(int i = 1; i<=n; ++i) scanf("%lld", a+i);
      |                            ~~~~~^~~~~~~~~~~~~
grow.cpp:19:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   char op; scanf(" %c", &op);
      |            ~~~~~^~~~~~~~~~~~
grow.cpp:21:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |    scanf("%d %d", &c, &h);
      |    ~~~~~^~~~~~~~~~~~~~~~~
grow.cpp:52:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |    scanf("%d %d", &l, &r);
      |    ~~~~~^~~~~~~~~~~~~~~~~
#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...
#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...