結果

問題 No.2625 Bouns Ai
ユーザー katonyonkokatonyonko
提出日時 2024-02-09 23:12:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 474 ms / 2,000 ms
コード長 2,200 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 224,388 KB
最終ジャッジ日時 2024-02-09 23:12:32
合計ジャッジ時間 10,653 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
67,084 KB
testcase_01 AC 43 ms
62,208 KB
testcase_02 AC 64 ms
70,912 KB
testcase_03 AC 364 ms
220,744 KB
testcase_04 AC 376 ms
220,696 KB
testcase_05 AC 362 ms
220,648 KB
testcase_06 AC 374 ms
220,664 KB
testcase_07 AC 361 ms
220,664 KB
testcase_08 AC 459 ms
222,816 KB
testcase_09 AC 433 ms
222,816 KB
testcase_10 AC 383 ms
220,680 KB
testcase_11 AC 52 ms
66,300 KB
testcase_12 AC 440 ms
222,816 KB
testcase_13 AC 434 ms
224,308 KB
testcase_14 AC 451 ms
224,292 KB
testcase_15 AC 437 ms
224,388 KB
testcase_16 AC 474 ms
224,324 KB
testcase_17 AC 460 ms
224,340 KB
testcase_18 AC 466 ms
224,340 KB
testcase_19 AC 447 ms
224,292 KB
testcase_20 AC 420 ms
224,308 KB
testcase_21 AC 458 ms
224,340 KB
testcase_22 AC 443 ms
224,292 KB
testcase_23 AC 464 ms
224,308 KB
testcase_24 AC 430 ms
224,324 KB
testcase_25 AC 421 ms
224,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import io
import sys
from collections import defaultdict, deque, Counter
from itertools import permutations, combinations, accumulate
from heapq import heappush, heappop
from bisect import bisect_right, bisect_left
from math import gcd
import math

_INPUT = """\
6
2
1 99998
1
0
9
31 41 59 26 53 58 97 93 23
"""

mod=998244353
class BIT:
    def __init__(self, n):
        self._n = n
        self.data = [0] * n
    def add(self, p, x):
        assert 0 <= p < self._n
        p += 1
        while p <= self._n:
            self.data[p - 1] = (self.data[p - 1]+x)%mod
            p += p & -p
    #合計にはrを含まない
    def sum(self, l, r):
        assert 0 <= l <= r <= self._n
        return (self._sum(r) - self._sum(l))%mod
    def _sum(self, r):
        s = 0
        while r > 0:
            s = (s+self.data[r - 1])%mod
            r -= r & -r
        return s
    #pの位置をxという値にセット
    def set(self, p, x):
        self.add(p, (-self.sum(p, p+1) + x)%mod)

def input():
  return sys.stdin.readline()[:-1]

def solve(test):
  N=int(input())
  A=list(map(int, input().split()))
  bit=[0]*(10**5+2)
  bit[A[0]]=1
  for i in range(N-1):
    bit2=[0]*(10**5+2)
    tmp=0
    for j in range(10**5+1):
      tmp+=bit[j]
      bit2[min(10**5+1,max(j,j-A[i]+A[i+1]))]+=tmp
      bit2[min(10**5+1,max(j,j-A[i]+A[i+1]))]%=mod
    bit=bit2
  ans=0
  tmp=0
  for i in range(10**5+1):
    tmp+=bit[i]
    ans=(ans+tmp)%mod
  print(ans)

def random_input():
  from random import randint,shuffle
  N=randint(1,10)
  M=randint(1,N)
  A=list(range(1,M+1))+[randint(1,M) for _ in range(N-M)]
  shuffle(A)
  return (" ".join(map(str, [N,M]))+"\n"+" ".join(map(str, A))+"\n")*3

def simple_solve():
  return []

def main(test):
  if test==0:
    solve(0)
  elif test==1:
    sys.stdin = io.StringIO(_INPUT)
    case_no=int(input())
    for _ in range(case_no):
      solve(0)
  else:
    for i in range(1000):
      sys.stdin = io.StringIO(random_input())
      x=solve(1)
      y=simple_solve()
      if x!=y:
        print(i,x,y)
        print(*[line for line in sys.stdin],sep='')
        break

#0:提出用、1:与えられたテスト用、2:ストレステスト用
main(0)
0