QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#676950 | #5674. Sum of Remainders | rand123 | WA | 0ms | 3728kb | C++20 | 1.6kb | 2024-10-26 04:47:29 | 2024-10-26 04:47:30 |
Judging History
answer
#include <bits/stdc++.h>
#define pii pair<int,int>
#define pb push_back
#define yes "YES"
#define no "NO"
#define ll long long
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define MOD2 998244353
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(int cas){
int n;
cin>>n;
vector<ll> s(n+1);
for (int i = 1; i <= n; i++) cin>>s[i];
int sz = s[1];
vector<ll> res(sz,1);
int nxt = 0;
for (int i = 2; i <= n; i++){
ll curr = 0;
for (int j = 0; j < nxt; j++){
curr+=i%res[j];
}
ll rem_pos = (sz - nxt)*i;
while (curr + rem_pos > s[i] && nxt < sz){
bool good = false;
for (int j = (nxt==0)?2:res[nxt-1]+1; j < i; j++){
if (((curr + i%j) + (sz-nxt-1)*i)==s[i]){
rem_pos = (sz-nxt-1)*i;
curr+=i%j;
good = true;
res[nxt] = j;
}
}
if (!good){
res[nxt] = i;
rem_pos = (sz-nxt-1)*i;
}
nxt++;
}
}
cout<<sz<<" ";
for (int i = 0; i < sz; i++) cout<<res[i]<<" ";
}
int main(){
int t=1;
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//cin>>t;
for (int i = 1; i<=t; i++){
solve(i);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3576kb
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: 3544kb
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: 0
Accepted
time: 0ms
memory: 3728kb
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 24 25
result:
ok single line: '7 7 12 13 14 15 24 25 '
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3536kb
input:
60 7 14 21 28 35 42 49 56 63 70 77 72 79 86 93 100 90 97 85 92 99 106 113 108 115 122 102 109 116 123 99 106 113 103 110 105 112 100 107 114 121 86 93 56 63 70 77 72 79 86 76 83 90 70 77 84 72 79 86 81
output:
7 6 17 19 27 31 36 44
result:
wrong answer 1st lines differ - expected: '7 12 17 19 27 31 42 44', found: '7 6 17 19 27 31 36 44 '