mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-09 16:58:48 +00:00
C - Long Sequence
https://atcoder.jp/contests/abc220/submissions/26156831
This commit is contained in:
parent
ceaf708b95
commit
8a288eac3f
33
AtCoder/ABC220/C/C.cpp
Normal file
33
AtCoder/ABC220/C/C.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user