比赛记录[Educational Codeforces Round 79 (Rated for Div. 2)]

首先声明,这是本蒟蒻第一次打CF,也是第一次发博客,大佬勿喷

  A                 B                 C              D              E               F

数学       贪心   N/A           N/A             N/A          N/A

A. New Year Garland

由于第一次打CF,比赛节奏和心态调整不太好,加上英文题目难以理解(本蒟蒻英语太垃圾),在第一题上水了15分钟.

第1题实际上就是理解题意,判断出a[3]<=a[1]+a[2]+1即可,核心代码:

 1 while(t--)
 2 {
 3     scanf("%lld%lld%lld",&a[1],&a[2],&a[3]);
 4     sort(a+1,a+1+3);
 5     if(a[3]<=a[1]+a[2]+1)
 6     {
 7         printf("Yes\n");
 8     }
 9     else
10     {
11         printf("No\n");
12     }
13 }        

B. Verse For Santa

这道第也在于对题意的理解,只要找好贪心的策略,就可以轻松解决,但细节比较多,导致我调了1个小时10分钟,这是思路上考虑不成熟的表现(太弱的表现)

核心代码:

 1 ll maxn=0,p=0,now=0;
 2 while(now+1<=n && sum+a[now+1]<=s)
 3 {
 4     now++;
 5     sum+=a[now];
 6     if(a[now]>maxn)
 7     {
 8         maxn=a[now];
 9         p=now;
10     }
11 }

输出时的细节代码:

 1 if(now==0)
 2 {
 3     printf("1\n");
 4     continue;
 5 }
 6 if(now+1<=n && maxn>=a[now+1])
 7 {
 8     printf("%lld\n",p);
 9 }
10 else if(now+2<=n && maxn<a[now+1] && a[now+1]>a[now+2])
11 {
12     printf("%lld\n",now+1);
13 }
14 else
15 {
16     printf("0\n");
17 }

本篇比赛记录就到此为止了,以后还会继续补充C,D,E,F题的做法

原文地址:https://www.cnblogs.com/wfzyd/p/12116046.html

时间: 2024-10-28 10:05:35

比赛记录[Educational Codeforces Round 79 (Rated for Div. 2)]的相关文章

Educational Codeforces Round 79 (Rated for Div. 2) D. Santa&#39;s Bot

链接: https://codeforces.com/contest/1279/problem/D 题意: Santa Claus has received letters from n different kids throughout this year. Of course, each kid wants to get some presents from Santa: in particular, the i-th kid asked Santa to give them one of

Educational Codeforces Round 79 (Rated for Div. 2)

A. New Year Garland (CF 1279 A) 题目大意 给定红绿蓝三种颜色灯的数量,问能否摆成一排,使得相邻颜色不相同. 解题思路 植树问题.考虑数量最多为\(n\)的颜色的灯俩俩不相邻,那么其他颜色的灯的数量和要大于\(n-1\)即可,大过\(n-1\)的灯直接插到里面就好了. 神奇的代码 #include <bits/stdc++.h> #define MIN(a,b) ((((a)<(b)?(a):(b)))) #define MAX(a,b) ((((a)>

Educational Codeforces Round 79 (Rated for Div. 2) C. Stack of Presents

链接: https://codeforces.com/contest/1279/problem/C 题意: Santa has to send presents to the kids. He has a large stack of n presents, numbered from 1 to n; the topmost present has number a1, the next present is a2, and so on; the bottom present has numbe

Educational Codeforces Round 69 (Rated for Div. 2) B - Pillars

Educational Codeforces Round 69 (Rated for Div. 2) B - Pillars There are n pillars aligned in a row and numbered from 1 to n. Initially each pillar contains exactly one disk. The i-th pillar contains a disk having radius ai. You can move these disks

Educational Codeforces Round 71 (Rated for Div. 2) D - Number Of Permutations

原文链接:https://www.cnblogs.com/xwl3109377858/p/11405773.html Educational Codeforces Round 71 (Rated for Div. 2) D - Number Of Permutations You are given a sequence of n pairs of integers: (a1,b1),(a2,b2),…,(an,bn). This sequence is called bad if it is

Educational Codeforces Round 69 (Rated for Div. 2) E. Culture Code

Educational Codeforces Round 69 (Rated for Div. 2) E. Culture Code 题目链接 题意: 给出\(n\)个俄罗斯套娃,每个套娃都有一个\(in_i,out_i\),并满足\(out_i>in_i\).定义套娃\(i\)能套在套娃\(j\)里面,当且仅当\(out_i\leq in_j\). 定义极大套娃组:当且仅当不能有另外一个套娃套在它们身上. 定义套娃组额外空间为\(in_1+(in_2-out_1)+\cdots +(in_k-

Educational Codeforces Round 73 (Rated for Div. 2)

比赛链接:Educational Codeforces Round 73 (Rated for Div. 2) 官方题解:Educational Codeforces Round 73 Editorial A. 2048 Game 题意 如果一个只包含 \(2\) 的幂次的集合,问能否从中选择一些数使得和为 \(2048\). 思路 不断合并直到凑到 \(2048\). 代码 #include <bits/stdc++.h> using namespace std; int main() {

Educational Codeforces Round 76 (Rated for Div. 2) E. The Contest

Educational Codeforces Round 76 (Rated for Div. 2) E. The Contest(dp+线段树) 题目链接 题意: 给定3个人互不相同的多个数字,可以把数字移动给别人,问最少移动几次后可以使第一个人的数字为1~m1,第二个人m1~m2,第三个人m2~n(可以没有数字) 题解: 设c[1][i]为第一个人m1为i时需要移动的次数,c[3][i]为m2为i是第三个人需要操作的次数,当其他两个人数字合法时,第二个人的数字也会合法.枚举第一个人的每个i,

Educational Codeforces Round 85 (Rated for Div. 2)

Educational Codeforces Round 85 (Rated for Div. 2) A. Level Statistics 签到题, 要求第一位维单增, 第二维变化比第一维慢, 直接模拟即可 B. Middle Class 题目大意 每个人有一些财富, 财富值超过x的人称为富人, 由于实行共产主义, 你可以将某些人的财产重新分配使得富人最多 解题思路 直接按财富值排序, 从大到小加入富人集合, 如果当前富人集合财富平均值小于x就break掉 C. Circle of Monst