Submission #602738

#TimeUsernameProblemLanguageResultExecution timeMemory
602738SifferDistributing Candies (IOI21_candies)C++17
0 / 100
127 ms9408 KiB
#include "candies.h" #include<bits/stdc++.h> using namespace std; vector<int> s; int gett(int i) { i += s.size()>>1; int r = 0; for(;i;i>>=1) r += s[i]; return r; } void up(int a, int b, int v) { a += s.size()>>1; b += s.size()>>1; for(;a <= b; a >>= 1, b >>= 1) { if(a&1) s[a] += v, a--; if((b&1)==0) s[b] += v, b--; } } vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) { int n = c.size(); int p = 1; for(;p <= n; p <<= 1); p <<= 1; s.resize(p,0); for(int i = 0; i < l.size(); i++) up(l[i],r[i],v[i]); vector<int> k(n,0); for(int i = 0; i < n; i++) k[i] = min(gett(i), c[i]); return k; }

Compilation message (stderr)

candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:26:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i = 0; i < l.size(); i++) up(l[i],r[i],v[i]);
      |                    ~~^~~~~~~~~~
#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...