题目链接 想了挺久,枚举每一件物品,当做关键物品,假设再加这一件物品,就>=c了,把剩下的物品背一下包,dp[i][j]表示i个物品可以组成重量j的个数. 这样就可以知道前面放i件,后边肯定放n-i-1件,乱搞搞,算double,边乘边算保证不要越界.最后注意,LL和sum <= c的时候情况. #include <iostream> #include <cstdio> #include <cstring> #include <vector> #…
Codeforces Round #160 (Div. 1) A - Maxim and Discounts 题意 给你n个折扣,m个物品,每个折扣都可以使用无限次,每次你使用第i个折扣的时候,你必须买q[i]个东西,然后他会送你{0,1,2}个物品,但是送的物品必须比你买的最便宜的物品还便宜,问你最少花多少钱,买完m个物品 题解 显然我选择q[i]最小的去买就好了 代码 #include<bits/stdc++.h> using namespace std; const int maxn =…
Codeforces Round #622 (Div. 2) A. Fast Food Restaurant 题意: 你是餐馆老板,虽然只会做三道菜,上菜时还有个怪癖:一位客人至少上一道菜,且一种菜最多上一次,所有客人菜单不能相同.给出三种菜的数量,问最多能接收多少客人. 思路: 一人一道 → 一人两道 → 一人三道. #include <bits/stdc++.h> using namespace std; int main() { int t;cin>>t; while(t--…
Hard problem 题目链接: http://codeforces.com/contest/706/problem/C Description Vasiliy is fond of solving different tasks. Today he found one he wasn't able to solve himself, so he asks you to help. Vasiliy is given n strings consisting of lowercase Engl…
A. Roma and Lucky Numbers 暴力计算. B. Roma and Changing Signs 每次取最小值改变正负,优先队列维护. C. Maxim and Discounts 贪心,当买的个数等于最小\(q_i\)时,能拿就拿. D. Maxim and Restaurant 枚举最后一个不能上桌的人\(x\),\(f(i,j)\)表示i个人凑成长为\(j\)的方案数,当\(j+a[x] \gt p\)时,前\(i\)个人可以随意排列,而没上桌的人除了\(x\)外也随意…
D. Maxim and Array 题目连接: http://codeforces.com/contest/721/problem/D Description Recently Maxim has found an array of n integers, needed by no one. He immediately come up with idea of changing it: he invented positive integer x and decided to add or…
题目链接:http://codeforces.com/problemset/problem/721/D D. Maxim and Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Recently Maxim has found an array of n integers, needed by no one. He…
D. Maxim and Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Recently Maxim has found an array of n integers, needed by no one. He immediately come up with idea of changing it: he in…
传送门 分析:其实没什么好分析的.统计一下负数个数.如果负数个数是偶数的话,就要尽量增加负数或者减少负数.是奇数的话就努力增大每个数的绝对值.用一个优先队列搞一下就行了. 我感觉这道题的细节极为多,非常复杂,其实是自己智障了.. 我看了一下学长菊苣的代码,好精巧...注释部分是他的代码 /*****************************************************/ //#pragma comment(linker, "/STACK:1024000000,10240…
Roma and Lucky Numbers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Roma (a popular Russian name that means 'Roman') loves the Little Lvov Elephant's lucky numbers. Let us remind you tha…