A. Strange Partition
题意:就是求最小和最大的bi/x向上取整的和。
思路:见题解:https://blog.csdn.net/qq_45900709/article/details/112341661
当时没想到的:就是不是说能够代替,不应该是平均以后再向上取整吗,尤其是等式的后一部分
代码:

 1 #include<iostream>
2 #include<algorithm>
3 #include<cstring>
4 #include<cstdio>
5 #include<cmath>
6 using namespace std;
7 const int maxx=1e5+10;
8 int main(){
9 int t;
10 scanf("%d",&t);
11 while(t--){
12 int n,x;
13 scanf("%d %d",&n,&x);
14 int a[maxx]={0};
15 long long int sum=0,y=0,summ=0;
16 for(int i=0;i<n;i++){
17 scanf("%d",&a[i]);
18 sum+=(a[i]/x);
19 if(a[i]%x!=0){
20 sum++;
21 }
22 summ+=a[i];
23 }
24 long long int mi=0,ma=0;
25 if(summ%x!=0){
26 mi++;
27 }
28 mi+=summ/x;
29 printf("%lld %lld\n",mi,sum);
30 }
31 }

B. Strange List

题意:设当前数为q,如果q能被x整除,在序列末端插入x个q/x,q移到下一位元素重复以上操作,如果不能就结束操作。求序列最终的和。

思路:其实这个是有规律的,插入x个q/x就是加q,只要q能被x整除就加q,一直到出现一个不能被x整除的数为止。也就是说,即使加入了x个q/x,那么和加q没什么区别

当时没想到的:1)本想着用数组,然后手写动态的数组,进行n++,然后存储空间太小,爆掉了;2)然后就想着要不要用队列,然后发现还是爆掉了;3)这种会RE或者会TLE的题目一定有简单的解法,一个是进行找找规律

代码:

 1 #include<iostream>
2 #include<algorithm>
3 #include<cstdio>
4 #include<cstring>
5 #include<cmath>
6 #include<queue>
7 using namespace std;
8 const long long int maxx=1e7;
9 long long int a[maxx];
10 long long int b[maxx];
11 int main(){
12 long long int t;
13 scanf("%lld",&t);
14 while(t--){
15 long long int n,x;
16 scanf("%lld %lld",&n,&x);
17 long long int sum=0;
18 queue<int> s;
19 for(long long int i=0;i<n;i++){
20 scanf("%lld",&a[i]);
21 b[i]=a[i];
22 sum+=a[i];
23 }
24 int flag=0;
25 while(!flag){
26
27 for(int i=0;i<n;i++){
28 if(b[i]%x){
29 flag=1;
30 break;
31 }
32 sum+=a[i];
33 b[i]/=x;
34 }
35
36 }
37 printf("%lld\n",sum);
38 }
39 }

C. Strange Birthday Party

题意:p有n位朋友,每位朋友有一个数ki。商店有m份礼物,第j份礼物价值cj美元,每份礼物只能买一次。当j<=ki时,p要么给第i位朋友价值为cj的礼物,要么直接给cki美元。问最小花费。

思路:注意c序列升序。对k序列降序处理,k值大的先选,避免较小的k值拿走较小的c值,最小值从c1开始,每次和cki比较取较小值。因为一个是第二个数组肯定是升序,这样的话,为了增大c中对应的cki和ci之间的差别,就应该倒置,因为c数组一定是从小到大

代码:

 1 #include<iostream>
2 #include<algorithm>
3 #include<cstdio>
4 #include<cstring>
5 #include<cmath>
6 #include<queue>
7 using namespace std;
8 const long long int maxx=3e5+10;
9 int a[maxx];
10 int b[maxx];
11 int main(){
12 long long int t;
13 scanf("%lld",&t);
14 while(t--){
15 int n,m;
16 scanf("%d %d",&n,&m);
17 for(int i=0;i<n;i++){
18 scanf("%d",&a[i]);
19 }
20 for(int i=0;i<m;i++){
21 scanf("%d",&b[i]);
22 }
23 int p=0;
24 sort(a,a+n);
25 int s=b[p++];
26 long long int sum=0;
27 for(int i=n-1;i>=0;i--){
28 if(b[a[i]-1]>s){
29 sum+=s;
30 s=b[p++];
31
32 }else{
33 sum+=b[a[i]-1];
34
35 }
36
37 }
38
39 printf("%lld\n",sum);
40 }
41 }

Codeforces Round #694 (Div. 2)的更多相关文章

  1. Codeforces Round #433 (Div. 2)【A、B、C、D题】

    题目链接:Codeforces Round #433 (Div. 2) codeforces 854 A. Fraction[水] 题意:已知分子与分母的和,求分子小于分母的 最大的最简分数. #in ...

  2. Codeforces Round #292 (Div. 1)A. Drazil and Factorial 构造

    A. Drazil and Factorial 题目连接: http://codeforces.com/contest/516/problem/A Description Drazil is play ...

  3. B. Ohana Cleans Up(Codeforces Round #309 (Div. 2))

    B. Ohana Cleans Up   Ohana Matsumae is trying to clean a room, which is divided up into an n by n gr ...

  4. B. The Number of Products(Codeforces Round #585 (Div. 2))

    本题地址: https://codeforces.com/contest/1215/problem/B 本场比赛A题题解:https://www.cnblogs.com/liyexin/p/11535 ...

  5. Codeforces Round #517 (Div. 2)(1~n的分配)

    题:https://codeforces.com/contest/1072/problem/C 思路:首先找到最大的x,使得x*(x+1)/2 <= a+b 那么一定存在一种分割使得 a1 &l ...

  6. Codeforces Round #805 (Div. 3)E.Split Into Two Sets

    题目链接:https://codeforces.ml/contest/1702/problem/E 题目大意: 每张牌上面有两个数字,现在有n张牌(n为偶数),问能否将这n张牌分成两堆,使得每堆牌中的 ...

  7. 贪心+构造( Codeforces Round #344 (Div. 2))

    题目:Report 题意:有两种操作: 1)t = 1,前r个数字按升序排列:   2)t = 2,前r个数字按降序排列: 求执行m次操作后的排列顺序. #include <iostream&g ...

  8. Codeforces Round #516 (Div. 2)D. Labyrinth(BFS)

    题目链接:http://codeforces.com/contest/1064/problem/D 题目大意:给你一个n*m的图,图中包含两种符号,'.'表示可以行走,'*'表示障碍物不能行走,规定最 ...

  9. Codeforces Round #281 (Div. 2) A. Vasya and Football 模拟

    A. Vasya and Football 题目连接: http://codeforces.com/contest/493/problem/A Description Vasya has starte ...

随机推荐

  1. Java并发编程之并发关键字

    volatile 保证可见性 一个线程修改volatile变量的值时,该变量的新值会立即刷新到主内存中,这个新值对其他线程来说是立即可见的 一个线程读取volatile变量的值时,该变量在本地内存中缓 ...

  2. 前端-CS-04

    一:DOM(文档对象模型) document 简写DOM 1.DOM中定义变量用 var  如下截图中:定义demo变量 2.取一个input输入框中的值的方法: 1)先如1中,在dom中顶一个一个变 ...

  3. 玩玩CSS,写一个图标堆叠效果

    遇到有人问如下效果怎么写,一时兴起,自己写一个玩玩. 看到这个样子,首先应该考虑一下 DOM 结构,以我的观点,把DOM结构设计为如下形式: <div> <img src=" ...

  4. PaddleOCR详解

    @ 目录 PaddleOCR简介 环境配置 PaddleOCR2.0的配置环境 Docker 数据集 文本检测 使用自己的数据集 文本识别 使用自己的数据集 字典 自定义字典 添加空格类别 文本角度分 ...

  5. Sqlmap的基础用法(禁止用于非法用途,测试请自己搭建靶机)

    禁止用于非法用途,测试与学习请自己搭建靶机 sqlmap -r http.txt  #http.txt是我们抓取的http的请求包 sqlmap -r http.txt -p username  #指 ...

  6. 4. Linux-startx命令

    Linux系统startx命令的功能和使用方法 Linux系统命令startx的功能很简单,就是启动X Window的服务这一项,没有其他的了.其实startx命令启动的是xinit,然后再由xini ...

  7. Tree UVA - 548

      You are to determine the value of the leaf node in a given binary tree that is the terminal node o ...

  8. Day17_101_IO_FileReaderAndFileWriterCopy

    IO_FileReaderAndFileWriterCopy * 代码: import java.io.FileNotFoundException; import java.io.FileReader ...

  9. 3、带你一步一步学习ASP.NET Core中的配置之Configuration

    如果你是刚接触ASP.NET Core的学习的话,你会注意到:在ASP.NET Core项目中,看不到.NET Fraemwork时代中的web.config文件和app.config文件了.那么你肯 ...

  10. 2021S软件工程——结对项目第一阶段

    # 2021S软件工程--结对项目第一阶段 2021春季软件工程(罗杰 任健) 项目地址 1020 1169 --- ## 1 结对感受 总体来说,结对编程与之前的个人编程感觉有很大的不同.有如下几个 ...