[acwing周赛复盘] 第 84 场周赛20221231
一、本周周赛总结
- 年末最后一场,三水题福利局,究极无敌手速场。
- T1哈希计数,T2前缀和,T3推公式。
二、4788. 最大数量
链接: 4788. 最大数量
1. 题目描述
2. 思路分析
定级Easy。
签到题,明显只要m和k同时大于等于n即可。
3. 代码实现
# Problem: 最大数量
# Contest: AcWing
# URL: https://www.acwing.com/problem/content/4791/
# Memory Limit: 256 MB
# Time Limit: 1000 ms
#
# Powered by CP Editor (https://cpeditor.org)
import sys
import bisect
import random
import io, os
from bisect import *
from collections import *
from contextlib import redirect_stdout
from itertools import *
from math import sqrt, gcd, inf
from array import *
from functools import lru_cache
from types import GeneratorType
from heapq import *
RI = lambda: map(int, sys.stdin.buffer.readline().split())
RS = lambda: map(bytes.decode, sys.stdin.buffer.readline().strip().split())
RILST = lambda: list(RI())
DEBUG = lambda *x: sys.stderr.write(f'{str(x)}\n')
MOD = 10 ** 9 + 7
if __name__ == '__main__':
n, = RI()
c = Counter()
for _ in range(n):
h, m = RI()
c[h * 60 + m] += 1
print(max(c.values()))
三、4789. 前缀和序列
链接: 4789. 前缀和序列
1. 题目描述
2. 思路分析
裸的前缀和。
3. 代码实现
# Problem: 前缀和序列
# Contest: AcWing
# URL: https://www.acwing.com/problem/content/4792/
# Memory Limit: 256 MB
# Time Limit: 1000 ms
#
# Powered by CP Editor (https://cpeditor.org)
import sys
import bisect
import random
import io, os
from bisect import *
from collections import *
from contextlib import redirect_stdout
from itertools import *
from math import sqrt, gcd, inf
from array import *
from functools import lru_cache
from types import GeneratorType
from heapq import *
RI = lambda: map(int, sys.stdin.buffer.readline().split())
RS = lambda: map(bytes.decode, sys.stdin.buffer.readline().strip().split())
RILST = lambda: list(RI())
DEBUG = lambda *x: sys.stderr.write(f'{str(x)}\n')
MOD = 10 ** 9 + 7
if __name__ == '__main__':
n, = RI()
a = RILST()
aa = [0] + list(accumulate(a))
bb = [0] + list(accumulate(sorted(a)))
def calc(p, l, r):
return p[r + 1] - p[l]
m, = RI()
for _ in range(m):
t, l, r = RI()
p = aa if t == 1 else bb
print(calc(p, l - 1, r - 1))
四、4790. 买可乐
链接: 4790. 买可乐
1. 题目描述
2. 思路分析
分类讨论即可。
3. 代码实现
# Problem: 买可乐
# Contest: AcWing
# URL: https://www.acwing.com/problem/content/4793/
# Memory Limit: 256 MB
# Time Limit: 1000 ms
#
# Powered by CP Editor (https://cpeditor.org)
import sys
import bisect
import random
import io, os
from bisect import *
from collections import *
from contextlib import redirect_stdout
from itertools import *
from math import sqrt, gcd, inf
from array import *
from functools import lru_cache
from types import GeneratorType
from heapq import *
RI = lambda: map(int, sys.stdin.buffer.readline().split())
RS = lambda: map(bytes.decode, sys.stdin.buffer.readline().strip().split())
RILST = lambda: list(RI())
DEBUG = lambda *x: sys.stderr.write(f'{str(x)}\n')
MOD = 10 ** 9 + 7
def solve():
c, d = RI()
n, m = RI()
k, = RI()
t = m * n
if k >= t:
return print(0)
if d * n <= c:
return print(d * (t - k))
diff = t - k
x, y = divmod(diff, n)
a = x * c + y * d
b = (x + 1) * c
print(min(a, b))
if __name__ == '__main__':
solve()
六、参考链接
- 无