0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-18 16:51:59 +00:00
OI-codes/AtCoder/ABC220/C/C.cpp

34 lines
575 B
C++
Raw Normal View History

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
int n;
long long a[100005], b, x, s, ans;
int main() {
std::ios::sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
b += a[i];
}
cin >> x;
s = (x / b) * b;
ans = (x / b) * n;
if (x % b == 0) {
cout << ++ans << endl;
exit(0);
}
for (int i = 1; i <= n; i++) {
s += a[i];
if (s > x) {
ans += i;
break;
}
}
cout << ans << endl;
return 0;
}