[ An Ac a Day ^_^ ] CodeForces 680A Bear and Five Cards

这两天回家了

家里电脑太卡 调试不方便

就只能写写水题了……

 1 #include<stdio.h>
 2 #include<iostream>
 3 #include<algorithm>
 4 #include<math.h>
 5 #include<string.h>
 6 #include<string>
 7 #include<map>
 8 #include<set>
 9 #include<vector>
10 #include<queue>
11 #define M(a,b) memset(a,b,sizeof(a))
12 using namespace std;
13 typedef long long ll;
14 int cnt[105];
15 int main(){
16     int a,max_=-1,sum=0,cost=0;
17     for(int i=0;i<5;i++){
18         scanf("%d",&a);
19         sum+=a;
20         cnt[a]++;
21         if(cnt[a]==2)
22             cost=a*2;
23         else if(cnt[a]>=3)
24             cost=a*3;
25         if(cost>max_)
26             max_=cost;
27     }
28     printf("%d\n",sum-max_);
29     return 0;
30 }
31 /*
32
33 7 3 7 3 20
34
35 7 9 3 1 8
36
37 10 10 10 10 10
38
39 */
时间: 2024-08-07 17:02:36

[ An Ac a Day ^_^ ] CodeForces 680A Bear and Five Cards的相关文章

codeforces 680A A. Bear and Five Cards(水题)

题目链接: A. Bear and Five Cards //#include <bits/stdc++.h> #include <vector> #include <iostream> #include <queue> #include <cmath> #include <map> #include <cstring> #include <algorithm> #include <cstdio>

Codeforces 385C Bear and Prime Numbers(素数预处理)

Codeforces 385C Bear and Prime Numbers 其实不是多值得记录的一道题,通过快速打素数表,再做前缀和的预处理,使查询的复杂度变为O(1). 但是,我在统计数组中元素出现个数时使用了map,以至于后面做前缀和的累加时,每次都要对map进行查询,以至于TLE.而自己一直没有发现,以为是欧拉筛对于这道题还不够优,于是上网搜题解,发现别人的做法几乎一样,但是却能跑过,挣扎了许久才想起是map的原因.map的内部实现是一颗红黑树,每次查询的复杂度为O(logN),在本来时

bear and five cards

#include<stdio.h>int main(){    int a[5],flag[2]={1,1},same[2]={0},ans=0;    for(int i=0;i<5;i++)    {        scanf("%d",&a[i]);        ans+=a[i];    }    for(int k=0,i=0;i<5;i++)    {        if(flag[k]>1) k++;        for(int

Codeforces 385D - Bear and Floodlight

385D - Bear and Floodlight 题目大意:有一个人从( l , 0 ) 想走到 ( r , 0 ),有 n 盏路灯,位置为( xi , yi ),每盏路灯都有一个照射的角度ai 这个角度内的区间都被照亮,问你走之前任意调路灯的方向,这个人只能走路灯照亮的地方,问你他最多能往 r 方向走多少距离. 思路:本来我想的是才20盏灯直接枚举灯的顺序也不会超时的吧,复杂度才20!* 20,结果GG,T掉了,改成 状态压缩就过了,状态压缩也跑了2000+ms.dp[ i ],表示 i

CodeForces 573A Bear and Poker

题目链接:http://codeforces.com/problemset/problem/573/A 题目大意:此题要求一组数中的元素乘以2或者乘以3后得到的数都一样,其实就是判断这些数除去2和3这些因子后剩下的因子都是一样的即可. AC代码: #include <cstdio> #include <cmath> #include <cstring> #include <iostream> using namespace std; #define M 10

Codeforces A - Bear and Prime 100(交互题)

A - Bear and Prime 100 思路:任何一个合数都可以写成2个以上质数的乘积.在2-100中,除了4,9,25,49外都可以写成两个以上不同质数的乘积. 所以打一个质数加这四个数的表:{2,3,4,5,7,9,11,13,17,19,23,25,29,31,37,41,43,47,49},询问19次,如果能被整出两次以上,说明是合数,否则是质数. #include<bits/stdc++.h> using namespace std; #define ll long long

Codeforces 679B - Bear and Tower of Cubes

679B - Bear and Tower of Cubes 题目大意:一个数x定义一种拆分方式,每次拆分取最大的a 且 a^3<=x,x减去a^3,之后重复同样的操作,直到 x变为0.给你一个数m( m<=1e15 ),让你取一个数q<=m,q能执行的操作数在小于等于m的数里面最大,且在操作数 最大的里面,值是最大的. 感觉这种思维题就是特别难.... 思路:设a为当前小于等于m的最大立方数.则对于当前的 m 我们有两种情况要考虑,第一种是res1=m-a^3 第二种是不想减去a^3,

Codeforces 385B Bear and Strings

题目链接:Codeforces 385B Bear and Strings 记录下每一个bear的起始位置和终止位置,然后扫一遍记录下来的结构体数组,过程中用一个变量记录上一个扫过的位置,用来去重. #include <iostream> #include <cstdio> #include <cstring> using namespace std; const int MAX_N = 5000 + 100; char str[MAX_N]; struct Node

codeforces 573C Bear and Drawing

Limak is a little bear who learns to draw. People usually start with houses, fences and flowers but why would bears do it? Limak lives in the forest and he decides to draw a tree. Recall that tree is a connected graph consisting of n vertices and n -