QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#511346 | #7845. Fast Forward | zzz111 | WA | 0ms | 3800kb | C++20 | 1.6kb | 2024-08-09 19:22:25 | 2024-08-09 19:22:26 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define pii pair<int, int>
#define fr(i, a, b) for (int(i) = (a); (i) <= (b); (i)++)
#define br(i, a, b) for (int(i) = (a); (i) >= (b); (i)--)
#define PI acos(-1)
using namespace std;
const int maxn = 14e2 + 3;
inline void solve()
{
int n, c;
cin >> n >> c;
vector<int> a(2 * n + 1);
vector<int> kan(2 * n + 1, 0);
fr(i, 1, n)
{
cin >> a[i];
a[i + n] = a[i];
}
int sum = 0;
set<int> st;
fr(i, 1, 2 * n)
{
sum += a[i];
if (sum >= c)
{
st.insert(i + 1);
kan[i] = kan[i - 1] + 1;
sum = 0;
}
else
kan[i] = kan[i - 1];
}
vector<int> ans(n + 1);
for (int i = 1; i <= n; i++)
{
int sum = 0;
int cnt = 0;
int j = i;
for (j = i; j <= i + n - 1; j++)
{
if (sum == 0 && *st.lower_bound(j) == j)
{
ans[i] = cnt + kan[i + n - 2] - kan[j] ;
break;
}
sum += a[j];
if(sum >= c && j != i + n - 1)
{
cnt++;
sum = 0;
}
}
if(j == i + n - 1)
ans[i] = cnt;
}
fr(i, 1, n)
{
if(i != 1)
cout << " ";
cout << ans[i];
}
}
signed main()
{
// ios::sync_with_stdio(false);
// cin.tie(0), cout.tie(0);
int T;
T = 1;
while (T--)
{
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3596kb
input:
7 7 1 1 1 1 1 1 1
output:
0 0 0 0 0 0 0
result:
ok single line: '0 0 0 0 0 0 0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
3 3 1 1 3
output:
0 1 1
result:
ok single line: '0 1 1'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3800kb
input:
10 5 4 1 5 5 1 3 2 1 5 2
output:
4 3 4 3 4 5 4 4 5 4
result:
wrong answer 1st lines differ - expected: '5 4 5 4 4 5 4 4 5 4', found: '4 3 4 3 4 5 4 4 5 4'