[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()

六、参考链接

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值