Id Date User Problem Result Time Mem Lang
140719 31/10/2019 5:55:13 jc C - Carrying pumpkins Accepted 359 1.2 MiB GNU G++17 7.3.0
Code
x
 
1
/**
2
 * code generated by JHelper
3
 * More info: https://github.com/AlexeyDmitriev/JHelper
4
 * @author jcg
5
 */
6
7
#include <iostream>
8
9
#include <iostream>
10
#include <vector>
11
12
class TaskC
13
{
14
public:
15
    void solve(std::istream& in, std::ostream& out)
16
    {
17
        int N, Q;
18
        in >> N >> Q;
19
        std::vector<long long> ws(N);
20
        for (auto &w : ws) in >> w;
21
        while (Q--)
22
        {
23
            long long q;
24
            in >> q;
25
            long long sum = 0, ans = 0;
26
            for (int i = -1, j = 0; j < N; ++j)
27
            {
28
                sum += ws[j];
29
                while (sum > q)
30
                    sum -= ws[++i];
31
                ans += j - i;
32
            }
33
            out << ans << '\n';
34
        }
35
    }
36
};
37
38
39
int main()
40
{
41
    std::ios_base::sync_with_stdio(0);
42
    std::istream& in(std::cin);
43
    std::ostream& out(std::cout);
44
    in.tie(0);
45
    TaskC solver;
46
    solver.solve(in, out);
47
    return 0;
48
}
Judgement Details
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