qiao

AcWing

1.4万

78岁扶墙对抗
MrYFX

ailaoli

o_28

will26
Aspiring_9

L_722

SeiunSky
cai_bird_565

qiao
3天前
N = 10 ** 5 + 10
n, m = map(int, input().split())
a, b = [0] * N, [0] * N
for i in range(n):
a[i], b[i] = map(int, input().split())

def check(x):
res = 0
for i in range(n):
if a[i] >= x:
res += (a[i] - x) // b[i] + 1
return res >= m

l, r = 0, 10 ** 6
while l < r:
mid = l + r + 1 >> 1
if check(mid):
l = mid
else:
r = mid - 1

x = l
res = 0
cnt = 0
for i in range(n):
if a[i] >= x:
n = (a[i] - x) // b[i] + 1
cnt += n
res += (2 * a[i] - b[i] * (n - 1)) * n // 2
print(res - (cnt - m) * x)



qiao
4天前
N = 10 ** 5 + 10
cnt = [0] * N
b = [0] * N

n = int(input())
a = [0] + list(map(int, input().split()))
m = int(input())
while m:
m -= 1
l, r = map(int, input().split())
b[l] += 1
b[r + 1] -= 1

for i in range(1, n + 1):
b[i] += b[i - 1]

sum = 0
for i in range(1, n + 1):
sum += a[i] * b[i]

a = [0]+sorted(a[1:n + 1])
b = [0]+sorted(b[1:n + 1])

res = 0
for i in range(1, n + 1):
res += a[i] * b[i]
print(res - sum)



qiao
4天前

n=int(input())
a=[0]+list(map(int,input().split()))
s=[0]*200010
for i in range(1,n+1):
s[i]+=a[i]+s[i-1]

res=0
for i in range(1,n):
res+=a[i]*(s[n]-s[i])
print(res)


qiao
5天前
s = list(input())
flag = 1
while flag:
flag = 0
vis = [0] * len(s)
for i in range(1, len(s) - 1):
if s[i - 1] != s[i] and s[i] == s[i + 1]:
vis[i - 1] = vis[i] = 1
flag = 1
if s[i - 1] == s[i] and s[i] != s[i + 1]:
vis[i + 1] = vis[i] = 1
flag = 1
t = []
for i in range(len(s)):
if vis[i] == 0:
t.append(s[i])
s = t

if len(s):
for t in s:
print(t, end='')
else:
print("EMPTY")



qiao
5天前
s = list(input())
flag = 1
while flag:
flag = 0
vis = [0] * len(s)
for i in range(1, len(s) - 1):
if s[i - 1] != s[i] and s[i] == s[i + 1]:
vis[i - 1] = vis[i] = 1
flag = 1
if s[i - 1] == s[i] and s[i] != s[i + 1]:
vis[i + 1] = vis[i] = 1
flag = 1
t = []
for i in range(len(s)):
if vis[i] == 0:
t.append(s[i])
s = t

if len(s):
for t in s:
print(t, end='')
else:
print("EMPTY")



qiao
5天前
from collections import defaultdict

N = 100010
h = defaultdict(int)  # h[x]:记录x出现过的最大位置
f = [0] * N  # f[r]:以r为右边界的满足题意最靠右的位置
n, m, x = map(int, input().split())
a = [0] + list(map(int, input().split()))
for i in range(1, n + 1):
f[i] = max(f[i - 1], h[x ^ a[i]])
h[a[i]] = i

while m:
m -= 1
l, r = map(int, input().split())
if f[r] >= l:
print("yes")
else:
print("no")



qiao
5天前
from collections import defaultdict

N = 100010
h = defaultdict(int)  # h[x]:记录x出现过的最大位置
f = [0] * N  # f[r]:以r为右边界的满足题意最靠右的位置
n, m, x = map(int, input().split())
a = [0] + list(map(int, input().split()))
for i in range(1, n + 1):
f[i] = max(f[i - 1], h[x ^ a[i]])
h[a[i]] = i

while m:
m -= 1
l, r = map(int, input().split())
if f[r] >= l:
print("yes")
else:
print("no")



qiao
5天前
N = 10 ** 6 + 10
a = []
n = int(input())
m = int(input())

def f(x):
res = 0
while x:
res += x % 10
x //= 10
return res

for i in range(1, n + 1):
a.append((f(i), i))

a.sort()
print(a[m-1][1])



qiao
5天前

n=int(input())
a=[0]+list(map(int,input().split()))
s=[0]*200010
for i in range(1,n+1):
s[i]+=a[i]+s[i-1]

res=0
for i in range(1,n):
res+=a[i]*(s[n]-s[i])
print(res)


qiao
5天前

a,b=1189,841
s=list(input())
n=int(s[1])

for i in range(n):
t=a//2
a=b
b=t
print(a)
print(b)