QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#30632#975. GameRivenOmega#WA 154ms17416kbC++14929b2022-04-30 17:05:212022-04-30 17:05:21

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-30 17:05:21]
  • Judged
  • Verdict: WA
  • Time: 154ms
  • Memory: 17416kb
  • [2022-04-30 17:05:21]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
const int N=5e5+5,Mod=998244353,iM=(Mod+1)>>1;
typedef long long ll;
ll a[N],pre[N],suf[N];
inline int po(int x, int y)
{
    int r=1;
    for(;y;y>>=1,x=1ll*x*x%Mod) if(y&1) r=1ll*r*x%Mod;
    return r;
}
set<pair<int,ll>> s;
priority_queue<pair<ll,int>> q;
int main()
{
    int n; scanf("%d",&n);
    for(int i=1;i<=n;++i) scanf("%lld",&a[i]);
    int ans=(a[1]+a[n])%Mod;
    s.insert(make_pair(1,a[1]));
    s.insert(make_pair(n,a[n]));
    for(int i=2;i<n;++i) q.push(make_pair(a[i],i));
    while(!q.empty())
    {
        ll w=q.top().first;
        int i=q.top().second;
        q.pop();
        auto itr=s.lower_bound(make_pair(i,0)),itl=itr; --itl;
        ll w2=itr->second+itl->second;
        if(w2 > 2ll*w) ans=(ans+w2%Mod*iM)%Mod;
        else ans=(ans+w)%Mod,s.insert(make_pair(i,w));
    }
    printf("%d\n",1ll*ans*po(n,Mod-2)%Mod);
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 5892kb

input:

3
3 1 2

output:

499122179

result:

ok "499122179"

Test #2:

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

input:

6
6 1 2 5 3 4

output:

582309211

result:

ok "582309211"

Test #3:

score: -100
Wrong Answer
time: 154ms
memory: 17416kb

input:

500000
131592496991 614154464278 882215024371 954828734583 997777248498 677111110098 927405745589 218490006270 743425189504 391435077446 972647376673 630405853326 714899101544 90679613430 530369364312 763893201576 838136940841 261795310871 187042095193 941416320169 688136558810 554872601435 54089147...

output:

481832772

result:

wrong answer 1st words differ - expected: '131032905', found: '481832772'