QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#78493 | #5517. Adjacent Product Sum | mikeac | TL | 22ms | 8780kb | Python3 | 664b | 2023-02-19 09:54:57 | 2023-02-19 09:54:57 |
Judging History
answer
import collections
import math
import random
import sys
from functools import *
from heapq import *
input = lambda: sys.stdin.readline().rstrip("\r\n")
ints = lambda: list(map(int, input().split()))
# MOD = 998244353
# MOD = 10 ** 9 + 7
def solve() -> None:
n = int(input())
arr = ints()
arr.sort(reverse=True)
res = collections.deque([])
for i in range(n):
if i % 2 == 1:
res.append(arr[i])
else:
res.appendleft(arr[i])
ans = res[0]*res[-1]
for i in range(n-1):
ans += res[i]*res[i+1]
print(ans)
t = int(input())
for _ in range(t):
solve()
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 22ms
memory: 8780kb
input:
4 3 1 2 3 6 1 1 1 1 0 0 5 100000 100000 100000 100000 -100000 5 1 2 3 4 5
output:
11 3 10000000000 48
result:
ok 4 number(s): "11 3 10000000000 48"
Test #2:
score: -100
Time Limit Exceeded
input:
1 200000 11009 633591 -419208 -664908 731171 -774644 -878270 656078 -38057 -220602 -897906 670165 -765931 -612936 -583782 -549624 -644245 137209 -983054 -110583 349193 699723 -412876 -417691 810865 -474314 -200632 570810 -283481 39600 20940 218215 -408751 -507326 -961614 600863 499517 -538207 767155...