QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#835986#9920. Money Game 2ucup-team055#WA 341ms10964kbC++203.2kb2024-12-28 15:51:472024-12-28 15:51:47

Judging History

This is the latest submission verdict.

  • [2024-12-31 22:17:02]
  • hack成功,自动添加数据
  • (/hack/1322)
  • [2024-12-31 21:57:13]
  • hack成功,自动添加数据
  • (/hack/1321)
  • [2024-12-28 15:51:47]
  • Judged
  • Verdict: WA
  • Time: 341ms
  • Memory: 10964kb
  • [2024-12-28 15:51:47]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const ll ILL=2167167167167167167;
const int INF=2100000000;
#define rep(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define all(p) p.begin(),p.end()
template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> ll LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> ll UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,T b){if(b<a){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
bool yneos(bool a,bool upp=0){if(a){cout<<(upp?"YES\n":"Yes\n");}else{cout<<(upp?"NO\n":"No\n");}return a;}
template<class T> void vec_out(vector<T> &p,int ty=0){
    if(ty==2){cout<<'{';for(int i=0;i<(int)p.size();i++){if(i){cout<<",";}cout<<'"'<<p[i]<<'"';}cout<<"}\n";}
    else{if(ty==1){cout<<p.size()<<"\n";}for(int i=0;i<(int)(p.size());i++){if(i) cout<<" ";cout<<p[i];}cout<<"\n";}}
template<class T> T vec_min(vector<T> &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmin(ans,x);return ans;}
template<class T> T vec_max(vector<T> &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmax(ans,x);return ans;}
template<class T> T vec_sum(vector<T> &a){T ans=T(0);for(auto &x:a) ans+=x;return ans;}
int pop_count(long long a){int res=0;while(a){res+=(a&1),a>>=1;}return res;}



void solve();
// CITRUS CURIO CITY / FREDERIC
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    cin >> t;
    rep(i, 0, t) solve();
}

void solve(){
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];
    const int D = 35;
    auto safe_add = [&](int a, int b) -> int {
        return ((a + b) % N + N) % N;
    };
    vector<ll> ans(N);
    rep(i, 0, N){
        if (N >= D * 2 + 1){
            int ind = safe_add(i, -D);
            ll val = A[ind];
            rep(i, 0, D - 1){
                val /= 2;
                ind = safe_add(ind, 1);
                val += A[ind];
            }
            ans[i] += A[i];
            ans[i] += val / 2;
            ind = safe_add(i, D);
            val = A[ind];
            rep(i, 0, D - 1){
                val /= 2;
                ind = safe_add(ind, -1);
                val += A[ind];
            }
            ans[i] += val / 2;
        }
        else{
            rep(j, 0, N){
                ll tmp = 0;
                int ind = j;
                ll val = A[ind];
                while (ind != i){
                    val /= 2;
                    ind = safe_add(ind, 1);
                    val += A[ind];
                }
                tmp += val - A[i];
                ind = safe_add(j, -1);
                val = A[ind];
                while (ind != i){
                    val /= 2;
                    ind = safe_add(ind, -1);
                    val += A[ind];
                }
                tmp += val;
                chmax(ans[i], tmp);
            }
        }
    }
    vec_out(ans);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3552kb

input:

3
5
2 1 4 3 5
5
2 1 3 1 2
1
1000000000

output:

6 5 7 8 8
4 4 5 4 4
1000000000

result:

ok 11 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

1
10
8 15 18 15 13 4 14 4 17 5

output:

30 37 41 39 34 27 29 26 31 27

result:

ok 10 numbers

Test #3:

score: 0
Accepted
time: 1ms
memory: 3592kb

input:

1000
4
8 9 7 9
1
9
1
10
2
3 9
3
4 3 2
4
0 4 3 1
4
10 8 4 6
1
9
1
4
4
10 10 1 6
1
9
1
0
2
4 6
4
8 1 6 7
2
5 10
4
9 2 1 4
3
5 5 9
3
9 8 9
4
4 8 5 6
2
10 1
1
7
3
9 2 4
4
2 4 1 2
3
5 2 1
1
4
3
2 0 9
4
7 3 10 1
3
4 1 2
2
6 4
1
2
3
3 1 5
3
5 8 4
2
9 3
4
5 9 10 3
4
6 5 4 0
1
6
4
3 1 10 1
4
1 9 5 7
4
8 1 6 ...

output:

18 18 17 18
9
10
7 10
6 6 5
3 5 5 3
18 16 13 15
9
4
18 17 11 14
9
0
7 8
13 9 11 14
10 12
12 7 6 9
11 11 13
17 16 17
12 14 13 12
10 6
7
12 8 9
5 6 4 4
6 4 4
4
6 5 10
11 11 13 10
5 4 4
8 7
2
5 4 6
11 12 10
10 7
13 17 16 12
9 10 8 6
6
6 7 11 7
9 13 12 11
14 10 12 16
18 15 18 19
5
11 13
4 4 6 7
12 14 13...

result:

ok 2420 numbers

Test #4:

score: 0
Accepted
time: 1ms
memory: 3560kb

input:

1000
2
45733740 736448710
1
384264719
4
658671808 379716865 553196572 534986092
1
668964623
4
711670857 237459905 849354895 187613938
2
394629064 371184128
2
616819808 937720703
1
43217931
3
934395080 888433507 810476236
1
587663687
2
542163302 508453558
4
313836277 584869499 445629251 225398284
4
2...

output:

413958095 759315580
384264719
1254322429 1119397578 1175216002 1235849498
668964623
1136546502 1064876265 1239809530 1027491789
580221128 568498660
1085680159 1246130607
43217931
1783849951 1760869165 1721890529
587663687
796390081 779535209
830377481 1020951833 929222211 751348422
704770986 7551365...

result:

ok 2440 numbers

Test #5:

score: -100
Wrong Answer
time: 341ms
memory: 10964kb

input:

1
500000
2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

wrong answer 1st numbers differ - expected: '4', found: '3'