結果
問題 | No.2548 Problem Selection |
ユーザー | tipstar0125 |
提出日時 | 2023-11-25 13:17:11 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 187 ms / 2,000 ms |
コード長 | 3,111 bytes |
コンパイル時間 | 177 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 110,720 KB |
最終ジャッジ日時 | 2024-09-26 10:24:42 |
合計ジャッジ時間 | 5,499 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 187 ms
104,692 KB |
testcase_01 | AC | 148 ms
91,008 KB |
testcase_02 | AC | 179 ms
110,720 KB |
testcase_03 | AC | 145 ms
89,792 KB |
testcase_04 | AC | 161 ms
100,480 KB |
testcase_05 | AC | 175 ms
110,156 KB |
testcase_06 | AC | 144 ms
89,344 KB |
testcase_07 | AC | 164 ms
103,064 KB |
testcase_08 | AC | 169 ms
105,088 KB |
testcase_09 | AC | 176 ms
107,520 KB |
testcase_10 | AC | 176 ms
110,224 KB |
testcase_11 | AC | 182 ms
110,144 KB |
testcase_12 | AC | 180 ms
110,592 KB |
testcase_13 | AC | 132 ms
89,216 KB |
testcase_14 | AC | 131 ms
89,088 KB |
testcase_15 | AC | 134 ms
89,048 KB |
testcase_16 | AC | 132 ms
88,996 KB |
testcase_17 | AC | 134 ms
88,960 KB |
testcase_18 | AC | 133 ms
89,244 KB |
testcase_19 | AC | 130 ms
89,052 KB |
testcase_20 | AC | 132 ms
89,216 KB |
testcase_21 | AC | 134 ms
89,344 KB |
testcase_22 | AC | 130 ms
89,344 KB |
testcase_23 | AC | 133 ms
89,344 KB |
testcase_24 | AC | 133 ms
89,344 KB |
testcase_25 | AC | 136 ms
89,216 KB |
testcase_26 | AC | 140 ms
88,888 KB |
ソースコード
from __future__ import annotations import array import bisect import copy import fractions import heapq import itertools import math import random import re import string import sys import time from collections import defaultdict, deque from functools import lru_cache sys.setrecursionlimit(10**6) def read_int_list(): return list(map(int, input().split())) def read_int(): return int(input()) def read_str_list(): return list(input().split()) def read_str(): return input() def is_prime(n: int) -> bool: if n < 2: return False i = 2 ok = True while i * i <= n: if n % i == 0: ok = False i += 1 return ok def eratosthenes(n: int) -> list[bool]: is_prime_list = ([False, True] * (n // 2 + 1))[0 : n + 1] is_prime_list[1] = False is_prime_list[2] = True for i in range(3, n + 1, 2): if not (is_prime_list[i]): continue if i * i > n: break for k in range(i * i, n + 1, i): is_prime_list[k] = False return is_prime_list def legendre(n: int, p: int) -> int: cnt = 0 pp = p while pp <= n: cnt += n // pp pp *= p return cnt def prime_factorize(n: int) -> defaultdict[int, int]: nn = n i = 2 d: defaultdict[int, int] = defaultdict(int) while i * i <= n: while nn % i == 0: d[i] += 1 nn //= i i += 1 if nn != 1: d[nn] += 1 return d def make_divisors(n: int) -> list[int]: i = 1 ret = [] while i * i <= n: if n % i == 0: ret.append(i) if i != n // i: ret.append(n // i) i += 1 ret.sort() return ret def gcd(a: int, b: int) -> int: if a == 0: return b else: return gcd(b % a, a) def lcm(a: int, b: int) -> int: return a * b // gcd(a, b) def ext_gcd(a: int, b: int) -> tuple[int, int, int]: if a == 0: return (0, 1, b) x, y, g = ext_gcd(b % a, a) return (y - b // a * x, x, g) class UnionFind: def __init__(self, n): self.parent = [-1] * n def find(self, x): if self.parent[x] < 0: return x else: self.parent[x] = self.find(self.parent[x]) return self.parent[x] def merge(self, x, y): x = self.find(x) y = self.find(y) if x != y: if self.parent[x] > self.parent[y]: x, y = y, x self.parent[x] += self.parent[y] self.parent[y] = x def same(self, x, y): return self.find(x) == self.find(y) def size(self, x): return -self.parent[self.find(x)] def solve(): N,M=read_int_list() A=read_int_list() ans=1<<60 A.sort() S=[0] for i in range(1,N): s=(A[i]-A[i-1])**2+S[-1] S.append(s) # print(A) # print(S) for i in range(0,N-M+1): # print(i, M+i-1) ans=min(ans, S[M+i-1]-S[i]) print(ans) def main(): # t = read_int() # for _ in range(t): solve() main()