(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #599150

#TimeUsernameProblemLanguageResultExecution timeMemory
599150lcjDistributing Candies (IOI21_candies)C++17
8 / 100
114 ms12980 KiB
#include <bits/stdc++.h> #include "candies.h" using namespace std; typedef long long ll; typedef pair<ll, ll> pll; typedef pair<int, int> pii; #define LSOne(s) ((s) & -(s)) struct Fenwick { vector<ll> ft; Fenwick(int n) : ft(n+1, 0) {} ll query(int i) { ll su = 0; for (; i > 0; i -= LSOne(i)) { su += ft[i]; } return su; } void update(int i, ll dv) { for (; i < ft.size(); i += LSOne(i)) { ft[i] += dv; } } }; vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) { int n = c.size(); Fenwick ft(n); for (int i = 0; i < l.size(); i++) { ft.update(r[i]+2, -v[i]); ft.update(l[i]+1, v[i]); } std::vector<int> s(n); for (int i = 0; i < n; i++) { s[i] = min(ft.query(i+1), (ll)c[i]); } return s; }

Compilation message (stderr)

candies.cpp: In member function 'void Fenwick::update(int, ll)':
candies.cpp:23:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         for (; i < ft.size(); i += LSOne(i))
      |                ~~^~~~~~~~~~~
candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:33:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for (int i = 0; i < l.size(); 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...