Codeforces Round #311 (Div. 2)A Ilya and Diplomas

【比赛链接】click here~~

【题目大意】

n个人,获取一到三等文凭,每门文凭有大小范围,求最后文凭各颁发多少

【解题思路】直接枚举了,

看完题,赶紧写了一发代码,发现居然错过注册时间,系统提示不能提交代码,真是醉了~~,以后还是得提前注册:

A题,比较简单:

代码:

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    int a1,a2;
    int b1,b2;
    int c1,c2;
    while(cin>>n)
    {
        cin>>a1>>a2;
        cin>>b1>>b2;
        cin>>c1>>c2;
        int max1=0,max2=0,max3=0;
        for(int i=a1;i<=a2;++i)
        {
            for(int j=b1;j<=b2;++j)
            {
              for(int k=c1;k<=c2;++k)
              {
                  max1=max(max1,i);
                  max2=max(max2,j);
                  max3=max(max3,k);
                  if(max1+max2+max3==n)
                  {
                      cout<<max1<<" "<<max2<<" "<<max3<<endl;
                      return 0;
                  }
              }
            }
        }
    }
    return 0;
}
/*
6
1 5
2 6
3 7
output
1 2 3
input
10
1 2
1 3
1 5
output
2 3 5
input
6
1 3
2 2
2 2
output
2 2 2
*/

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-08-04 10:17:32

Codeforces Round #311 (Div. 2)A Ilya and Diplomas的相关文章

递推 Codeforces Round #186 (Div. 2) B. Ilya and Queries

题目传送门 1 /* 2 递推:用cnt记录前缀值,查询区间时,两个区间相减 3 */ 4 #include <cstdio> 5 #include <algorithm> 6 #include <cmath> 7 #include <cstring> 8 using namespace std; 9 10 const int MAXN = 1e5 + 10; 11 const int INF = 0x3f3f3f3f; 12 char s[MAXN]; 1

贪心 Codeforces Round #297 (Div. 2) C. Ilya and Sticks

题目传送门 1 /* 2 题意:给n个棍子,组成的矩形面积和最大,每根棍子可以-1 3 贪心:排序后,相邻的进行比较,若可以读入x[p++],然后两两相乘相加就可以了 4 */ 5 #include <cstdio> 6 #include <algorithm> 7 #include <cstring> 8 #include <cmath> 9 using namespace std; 10 11 typedef long long ll; 12 13 co

Codeforces Round #311 (Div. 2) A,B,C,D,E

A. Ilya and Diplomas 思路:水题了, 随随便便枚举一下,分情况讨论一下就OK了. code: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <algorithm> #include <iostream> #include <cstring> #include <cmath> #define inf 1000000

2017-4-25-Train:Codeforces Round #311 (Div. 2)

A. Ilya and Diplomas(贪心) Soon a school Olympiad in Informatics will be held in Berland, n schoolchildren will participate there. At a meeting of the jury of the Olympiad it was decided that each of the n participants, depending on the results, will g

Codeforces Round #186 (Div. 2)---D. Ilya and Roads

Everything is great about Ilya's city, except the roads. The thing is, the only ZooVille road is represented as n holes in a row. We will consider the holes numbered from 1 to n, from left to right. Ilya is really keep on helping his city. So, he wan

Codeforces Round #311 (Div. 2)

D 分4种情况讨论 1 不需要加边 , 就是说原本就有一个奇数环,我们只要跑一次二分图就好了 2 加一条边 , 也就是说存在大于等于3个点的联通块 我们对于这个联通块也跑一遍二分图, 可以知道图中所有的 同颜色染色中的点任意相连,都是一个奇数环,那么对于每个联通分量都有相应的数可以计算 3 加两条边,也就是说没有大于两个点的联通块存在,并且有两个点的联通块存在,答案也是可以计算出来的 e*(n-2) 4 加三条边 那么就可以知道每个联通块只有一个点,答案是 n*(n-1)*(n-2)/6; #i

Codeforces Round #311 (Div. 2) E. Ann and Half-Palindrome (DP+字典树)

题目地址:传送门 先用dp求出所有的符合要求的半回文串,标记出来.然后构造字典树.然后再dfs一遍求出所有节点的子树和,最后搜一遍就能找出第k个来了. 代码如下: #include <iostream> #include <string.h> #include <math.h> #include <queue> #include <algorithm> #include <stdlib.h> #include <map>

Codeforces Round #293 (Div. 2) D. Ilya and Escalator (概率DP)

dp[i][j]表示第i秒电梯进去的人数为j时的概率.由于概率比较好求,而且这里的样本是有限个.所以可以先求出概率,然后用公式转化成期望. #include <iostream> #include <string.h> #include <math.h> #include <queue> #include <algorithm> #include <stdlib.h> #include <map> #include <

Codeforces Round #311 (Div. 2)--D(图

题意:给出一个图,问最少加多少条边能连出一个奇圈,还要求输出连边的方法种数. 思路:比赛的时候看了一下是图相关的就没多想,也没时间了,其实挺简单的,如果已经有奇圈,那么直接输出0 1,如果最多有两个点相连,那么就是(n-2)×m,就是每条边和另外的任意点连两条边,要么就是没有边,这个就是直接输出结果.. 稍微麻烦一点的是最后一种,联通块有多个点且没有奇圈,这时候需要把联通快黑白染色,同色的点相连就是一个奇圈,dfs的时候统计每个联通块中两种=颜色的个数即可. #include<bits/stdc