Id | Date | User | Problem | Result | Time | Mem | Lang |
---|---|---|---|---|---|---|---|
140719 | 31/10/2019 5:55:13 | jc | C - Carrying pumpkins |
|
359 | 1.2 MiB | GNU G++17 7.3.0 |
/**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author jcg
*/
#include <iostream>
#include <iostream>
#include <vector>
class TaskC
{
public:
void solve(std::istream& in, std::ostream& out)
{
int N, Q;
in >> N >> Q;
std::vector<long long> ws(N);
for (auto &w : ws) in >> w;
while (Q--)
{
long long q;
in >> q;
long long sum = 0, ans = 0;
for (int i = -1, j = 0; j < N; ++j)
{
sum += ws[j];
while (sum > q)
sum -= ws[++i];
ans += j - i;
}
out << ans << '\n';
}
}
};
int main()
{
std::ios_base::sync_with_stdio(0);
std::istream& in(std::cin);
std::ostream& out(std::cout);
in.tie(0);
TaskC solver;
solver.solve(in, out);
return 0;
}
Case#1 [430080 bytes][15 ms]: ok 4 tokens Case#2 [425984 bytes][0 ms]: ok 5 tokens Case#3 [425984 bytes][0 ms]: ok 5 tokens Case#4 [425984 bytes][0 ms]: ok 5 tokens Case#5 [425984 bytes][0 ms]: ok 5 tokens Case#6 [425984 bytes][15 ms]: ok 10 tokens Case#7 [425984 bytes][0 ms]: ok 20 tokens Case#8 [425984 bytes][0 ms]: ok 20 tokens Case#9 [425984 bytes][0 ms]: ok 20 tokens Case#10 [430080 bytes][0 ms]: ok 20 tokens Case#11 [425984 bytes][0 ms]: ok 10 tokens Case#12 [425984 bytes][0 ms]: ok 50 tokens Case#13 [425984 bytes][0 ms]: ok 50 tokens Case#14 [425984 bytes][0 ms]: ok 50 tokens Case#15 [434176 bytes][0 ms]: ok 100 tokens Case#16 [434176 bytes][0 ms]: ok 100 tokens Case#17 [434176 bytes][0 ms]: ok 100 tokens Case#18 [434176 bytes][0 ms]: ok 100 tokens Case#19 [462848 bytes][15 ms]: ok 100 tokens Case#20 [466944 bytes][15 ms]: ok 100 tokens Case#21 [589824 bytes][15 ms]: ok 100 tokens Case#22 [589824 bytes][62 ms]: ok 500 tokens Case#23 [1228800 bytes][359 ms]: ok 500 tokens Case#24 [1228800 bytes][328 ms]: ok 500 tokens Case#25 [1228800 bytes][359 ms]: ok 500 tokens Case#26 [1232896 bytes][328 ms]: ok 500 tokens