QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#179217 | #5674. Sum of Remainders | wdbl857 | WA | 1ms | 5692kb | C++20 | 1.4kb | 2023-09-14 19:42:40 | 2023-09-14 19:42:40 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define xx first
#define yy second
#define endl "\n"
#define lowbit(x) x & (-x)
#define int long long
#define ull unsigned long long
#define pb push_back
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define Ysanqian ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
const int N = 1e6 + 10, M = 1010, inf = 0x3f3f3f3f, mod = 18446, P = 13331;
const double eps = 1e-8;
int n;
int a[N];
bool flag;
vector<int> ans;
void solve()
{
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
int num = a[1];
int cnt = a[1];
for (int i = 2; i <= n; i++)
{
if (a[i] < cnt * i)
{
int sum = 0;
for (auto ed : ans)
sum += i % ed;
a[i] -= sum;
int x = a[i] / i;
int y = cnt;
y -= x;
cnt -= y;
for (int j = 1; j <= y; j++)
{
ans.pb(i);
if (ans.size() == a[1])
{
flag = 1;
break;
}
}
if (flag)
break;
}
}
cout << a[1] << ' ';
if (a[1] == 1)
cout << 2 << endl;
else
for (auto ed : ans)
cout << ed << ' ';
}
signed main()
{
Ysanqian;
int T;
T = 1;
// cin >> T;
while (T--)
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5692kb
input:
16 4 6 10 12 6 8 12 14 18 10 3 5 9 11 5 7
output:
4 2 5 5 11
result:
ok single line: '4 2 5 5 11 '
Test #2:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
20 3 6 6 9 12 6 2 5 5 8 11 5 8 4 4 7 10 4 7 10
output:
3 3 6 7
result:
ok single line: '3 3 6 7 '
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3596kb
input:
40 7 14 21 28 35 42 42 49 56 63 70 65 59 45 37 44 51 58 65 72 72 79 86 57 39 33 40 26 33 25 32 39 46 53 53 48 55 62 56 63
output:
7 7 12 13 14 15 25 25
result:
wrong answer 1st lines differ - expected: '7 7 12 13 14 15 24 25', found: '7 7 12 13 14 15 25 25 '