/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 74ms 21.988 MiB
#2 Wrong Answer 144ms 25.242 MiB
#3 Accepted 100ms 22.836 MiB
#4 Accepted 103ms 23.207 MiB
#5 Accepted 103ms 30.16 MiB
#6 Accepted 103ms 39.094 MiB
#7 Accepted 104ms 41.121 MiB
#8 Accepted 106ms 41.215 MiB
#9 Wrong Answer 151ms 25.223 MiB

Code

from collections import *        # Useful for deque, Counter, defaultdict, namedtuple, etc.
from itertools import *          # Provides tools for combinations, permutations, product, etc.
from functools import *          # Includes tools like lru_cache for memoization, reduce, etc.
from heapq import *              # Provides heap operations like heappush, heappop, useful for priority queues
from bisect import *             # For efficient binary search and maintaining sorted lists
from math import *               # Includes functions like gcd, sqrt, factorial, isqrt, comb, etc.
from operator import *           # Includes functions like itemgetter, attrgetter, add, mul for functional programming
from array import *              # For efficient storage and manipulation of numeric arrays
from typing import *             # Provides typing hints (List, Tuple, Dict, etc.) to improve readability and error-checking
from decimal import *            # High-precision arithmetic operations, useful for certain precision tasks
from queue import *              # Includes Queue, LifoQueue, PriorityQueue useful in BFS, DFS, and other algorithms
import sys
sys.setrecursionlimit(10**5)
def POW(base, exp, mod):
    result = 1
    base = base % mod  # Handle case when base is larger than mod
    while exp > 0:
        if exp % 2 == 1:  # If exp is odd, multiply base with result
            result = (result * base) % mod
        exp = exp // 2    # Divide exp by 2
        base = (base * base) % mod  # Square the base
    return result
def IL():
  return [int(i) for i in input().split()]
def CL():
  return [i for i in input().split()]
def I():
  return input()
def inti():
  return int(input())
def db(x):
  return print(x)
def dbl(x):
  return print(*x)
def dbm(x):
  for i in x:
    print(i)
def sq(x):
  return x==int(x**0.5)**2
def prime(n):
    if n <= 1:
        return False
    if n <= 3:
        return True
    if (n & 1) == 0 or n % 3 == 0:
        return False
    i = 5
    while i * i <= n:
        if n % i == 0 or n % (i + 2) == 0:
            return False
        i += 6
    return True

char="abcdefghijklmnopqrstuvwxyz"
mod=pow(10,9)+7


for _ in range(int(input())):
  n,k,d=IL()
  arr=IL()
  pre=list(accumulate(arr))
  ans=-1
  for i in range(n-k+1):
    cur=pre[i+k-1]-(pre[i-1] if i>0 else 0)
    if cur%d==0 and ans==-1:
      ans=i+1
      break
  print(ans)
  

Information

Submit By
Type
Submission
Problem
P1190 Segment Strength
Contest
Brain Booster #9
Language
PyPy 3 (Python 3.9.18 PyPy 7.3.15)
Submit At
2025-04-06 16:14:30
Judged At
2025-04-06 16:14:30
Judged By
Score
75
Total Time
151ms
Peak Memory
41.215 MiB