Submission #68187633
Source Code Expand
import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import permutations from math import gcd,log input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) """ w0,w1,...,wn wi + wj > M (i!=j) だと困る 1. 全員 M/2 以下 2. そうでない場合、最大値をaとすると a + (M-a) * (N-1) = N*(N-1)-a*(N-2) が最大 """ def solve(N,M): res = (M//2) * N a = M//2 + 1 if a <= M: res = max(res,M*(N-1)-a*(N-2)) return res for _ in range(int(input())): N,M = mi() print(solve(N,M))
Submission Info
Submission Time | |
---|---|
Task | A - All Winners |
User | chinerist |
Language | Python (PyPy 3.10-v7.3.12) |
Score | 400 |
Code Size | 675 Byte |
Status | AC |
Exec Time | 155 ms |
Memory | 85292 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample.txt |
All | handmade.txt, random_1.txt, random_2.txt, random_3.txt, random_4.txt, random_5.txt, sample.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
handmade.txt | AC | 152 ms | 85248 KiB |
random_1.txt | AC | 128 ms | 85276 KiB |
random_2.txt | AC | 147 ms | 85156 KiB |
random_3.txt | AC | 119 ms | 85240 KiB |
random_4.txt | AC | 87 ms | 83180 KiB |
random_5.txt | AC | 155 ms | 85292 KiB |
sample.txt | AC | 85 ms | 83168 KiB |