-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA.cpp
More file actions
81 lines (68 loc) · 1.53 KB
/
Copy pathA.cpp
File metadata and controls
81 lines (68 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <string>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define uc unsigned char
#define ii pair<int, int>
#define llll pair<ll, ll>
#define vc vector
#define vi vc<int>
#define vll vc<ll>
#define vuc vc<unsigned int>
#define vvi vc<vi>
#define vvll vc<vll>
#define vvuc vc<vuc>
#define print cout <<
#define el endl
#define in cin >>
#define fast cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);
#define gcd __gcd
#define lcm __lcm
#define pc __builtin__popcount
#define ext return 0;
/******************************* CODE HERE *******************************/
int main()
{
int t;
int d;
int result;
int n;
int input;
int days;
cin >> t;
for (int i = 0; i < t; ++i)
{
cin >> n >> d;
cin >> result;
for (int j = 1; j < n; ++j)
{
cin >> input;
if (d > 0)
{
days = j * input;
if (days <= d)
{
result += input;
d -= days;
}
else
{
result += d/j;
d = -1;
}
}
}
cout << result << endl;
}
ext
}