D - Various Sushi Time Limit: 2 sec / Memory Limit: 1024 MB Score : 400400 points Problem Statement There are NN pieces of sushi. Each piece has two parameters: "kind of topping" titi and "deliciousness" didi. You are choosing KK among…
Problem Statement There are NN pieces of sushi. Each piece has two parameters: "kind of topping" titi and "deliciousness" didi. You are choosing KK among these NN pieces to eat. Your "satisfaction" here will be calculated as…
题目链接 题意就是要让给出的数字去互相取余,看看能得到最小的数事多少. 那么就可以从小到大排序,每一次都贪心地把最小的数作为攻击者,去攻击其他的数字(也就是大的取余小的),然后再一次排序,循环这个过程,直到出现1或者数字只剩一个非0数. 代码如下 #include <cstdio> #include <algorithm> using namespace std; ]; int main() { int n; scanf("%d", &n); ; i &…
[题意]一共有N个任务和M天,一个人一天只能做一个任务,做完任务之后可以在这一天之后的(Ai-1)天拿到Bi的工资,问M天内最多可以拿到多少工资. 链接:https://atcoder.jp/contests/abc137/tasks/abc137_d [思路]按时间将任务排序,把 ii 时刻能做的任务都扔进堆里 , 因为任务是一次性的,所以每个任务放进去过就不再放入了.然后每个时刻看一下堆里面有没有数,有的话就取堆顶出来,而且每个时刻只能取一次.正确性显然. 代码: #include<bits…
题意:有一长度为奇数\(n\)的数组\(a\),和长度为\(m\)的数组\(b\),现要求从\(b\)中选择一个数放到\(a\)中,并将\(a\)分成\((n+1)/2\)个数对,求最小的所有数对差的和. 题解:我们从\(b\)中选一个数出来,只和\(a\)中的一个元素配对,剩下的依然是\(a\)中\(n-1\)个数两两配对,所以我们可以先求个前缀/后缀和,然后枚举\(b\)在\(a\)中二分查找和\(b_i\)最近的数,但是会有个小问题,加入我们二分查找的位置是偶数,此时并不能完全配对,但是没…
传送门:F - Keep Connect (atcoder.jp) 题意: 给定长度为N的操作(ti,yi). 给定初值为0的x,对其进行操作:当t为1时,将x替换为y:当t为2时,将x加上y. 最多可以跳过k步,求最终x的最大值. 思路: 注意到,当t为1时,进行替换操作,那么该位置前面的操作是不会对后面产生任何影响的,也就不会消耗k. 那么我们可以枚举最后一次不跳过的1操作,对于该位置的前面无需考虑,对于该位置的后面:所有的1操作都应跳过(记数量为cnt),且对于2操作选择数值前k - cn…
C - Grand Garden In a flower bed, there are NN flowers, numbered 1,2,......,N1,2,......,N. Initially, the heights of all flowers are 00. You are given a sequence h={h1,h2,h3,......}h={h1,h2,h3,......} as input. You would like to change the height of…
目录 AtCoder Beginner Contest 153 题解 A - Serval vs Monster 题意 做法 程序 B - Common Raccoon vs Monster 题意 做法 程序 C - Fennec vs Monster 做法 程序 D - Caracal vs Monster 做法 程序 E - Crested Ibis vs Monster 做法 程序 F - Silver Fox vs Monster 做法 程序 感谢 AtCoder Beginner Co…
AtCoder Beginner Contest 173 题解 目录 AtCoder Beginner Contest 173 题解 A - Payment B - Judge Status Summary C - H and V D - Chat in a Circle E - Multiplication 4 F - Intervals on Tree A - Payment 首先我们可以把所有不用找零的部分都付掉,这样就只剩下了\(A \mod 1000\)这样一个"\(A\)除以\(10…
AtCoder Beginner Contest 172 题解 目录 AtCoder Beginner Contest 172 题解 A - Calc B - Minor Change C - Tsundoku D - Sum of Divisors E - NEQ F - Unfair Nim A - Calc 程序如下(真的有人需要嘛): #include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdi…