Codeforces Round #552 (Div. 3) Editorial 1154C - Gourmet Cat

链接:https://codeforces.com/contest/1154/problem/C

题意:一只旅行的小猫在特定的星期里吃特定的食物,一四七a,二六b,三五c,现在给三种食物的数量,问小猫最多能活几天。

思路:先看小猫能活几个整星期,因为a在一个星期里占三天,b和c各占两天,所以取min(a/3,b/2,c/2),然后求剩下的,这个时候就可以枚举日子了,从周一枚举到周日,然后模拟一哈就行了,虽然是个水题但我还是没做粗来

代码:

 1 //#include<bits/stdc++.h>
 2 #include<iostream>
 3 #include<vector>
 4 #include<stack>
 5 #include<string>
 6 #include<cstdio>
 7 #include<algorithm>
 8 #include<queue>
 9 #include<map>
10 #include<set>
11 #include<cmath>
12 #include<iomanip>
13 #define inf 0x3f3f3f3f
14 using namespace std;
15 typedef long long ll;
16 const int M = int(1e5) * 3 + 5;
17 vector<int> a(3);
18 signed main()
19 {
20     //int f, r, c;
21     cin >> a[0] >> a[1] >> a[2];
22     int k = min({ a[0] / 3,a[1] / 2,a[2] / 2 });  //min新用法√
23     int day[7] = { 0,1,2,0,2,1,0 };
24     a[0] -= k * 3;
25     a[1] -= k * 2;
26     a[2] -= k * 2;
27     int ans = 0;
28     for (int i = 0; i < 7; i++)
29     {
30         vector<int> b = a;  //vector新用法√
31         int j = i;
32         int cur = 0;
33         while (b[day[j]] > 0)
34         {
35             b[day[j]]--;
36             j = (j + 1) % 7;  //保证j在0到6的范围里
37             cur++;
38         }
39         ans = max(ans, k * 7 + cur);
40     }
41     cout << ans << endl;
42     return 0;
43 }

备注:这次cf让我看到我的实力有所下降,还有一个月就要校赛了,要把状态拉回来,基础要打牢,也要学新东西

原文地址:https://www.cnblogs.com/harutomimori/p/10733419.html

时间: 2024-08-29 17:21:56

Codeforces Round #552 (Div. 3) Editorial 1154C - Gourmet Cat的相关文章

Codeforces Round #590 (Div. 3) Editorial

Codeforces Round #590 (Div. 3) Editorial 题目链接 官方题解 不要因为走得太远,就忘记为什么出发! Problem A 题目大意:商店有n件商品,每件商品有不同的价格,找出一个最小的可能值price,使得price * n >= sum,sum指的是原来商品价格的总和. 知识点:模拟 思路:求出sum/n向上取整即可,有两种方法.一是使用ceil()函数,但注意ceil()返回的是向上取整后的浮点数,所以要进行强制类型转换:二是直接向下取整,然后用if语句

Codeforces Round #552 (Div. 3) C题

题目网址:http://codeforces.com/contest/1154/problem/C 题目意思:小猫吃三种食物,A,B,C,一周吃食物的次序是,A,B,C,A,C,B,A,当小猫该天无食物可吃时,就会饿死,现给出a,b,c三个数,表示A,B,C的食物数量, 选择一天开始,问小猫最多可以活到多少天. 题解:首先,在一周时间,A要吃三天,B要吃两天,C要吃两天,先随便选一天开始,当剩下食物不足以撑过一周时停止,再细分剩下的食物数量,看小猫饿 死是经过的最多天数.选择的天数用暴力写即可.

Codeforces Round #552(div.3)

Problem: http://codeforces.com/contest/1154 A: 1 /* basic header */ 2 #include <iostream> 3 #include <cstdio> 4 #include <cstdlib> 5 #include <string> 6 #include <cstring> 7 #include <cmath> 8 #include <cstdint> 9

Codeforces Round #552 (Div. 3)-D-Walking Robot-(贪心)

http://codeforces.com/contest/1154/problem/D 解题: 1.无光的时候优先使用太阳能电池. 2.有光的时候 (1)太阳能电池没满电,让它充,使用普通电池 (2)太阳能电池满电,使用太阳能电池 #include<stdio.h> #include<math.h> #include<string.h> #include<algorithm> #include<string> #include<vecto

Codeforces Round #552 (Div. 3)-1154E-Two Teams-(模拟+双指针)

http://codeforces.com/contest/1154/problem/E 解题: 举例n=10,k=1 1,2,10,4,7,6,9,8,5,3 第一次,1队先挑2,10,4这三个人 1,2,10,4,7,6,9,8,5,3 第二次,2队挑6,9,8三个人 1,2,10,4,7,6,9,8,5,3 第三次,1队挑1,7,5三个人 1,2,10,4,7,6,9,8,5,3 第四次,2队挑3一个人 1,2,10,4,7,6,9,8,5,3 显然需要实现的有两点 (1)挑完后的“连接”

Codeforces Round #552 (Div. 3) E C++

题目: E. Two Teams time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are nn students standing in a row. Two coaches are forming two teams — the first coach chooses the first team and the

Codeforces Round #541 (Div. 2) 题解

Codeforces Round #541 (Div. 2) 题目链接:https://codeforces.com/contest/1131 A. Sea Battle 题意: 给出两个矩形的宽和高,满足第一个矩形的左上顶点为(0,0),右下顶点为(w1,-h1):第二个矩形的坐下顶点为(0,0),右上顶点为(w2,h2).然后求围绕这两个矩形一圈的格子个数为多少. 题解: 利用二维前缀和的思路推导一下公式就行了,公式也有很多吧==我当时就是大概模拟了一下.. 代码如下: #include <

Codeforces Round #428 (Div. 2)

Codeforces Round #428 (Div. 2) A    看懂题目意思就知道做了 #include<bits/stdc++.h> using namespace std; #pragma comment(linker, "/STACK:102400000,102400000") #define rep(i,a,b) for (int i=a; i<=b; ++i) #define per(i,b,a) for (int i=b; i>=a; --i

Codeforces Round #424 (Div. 2) D. Office Keys(dp)

题目链接:Codeforces Round #424 (Div. 2) D. Office Keys 题意: 在一条轴上有n个人,和m个钥匙,门在s位置. 现在每个人走单位距离需要单位时间. 每个钥匙只能被一个人拿. 求全部的人拿到钥匙并且走到门的最短时间. 题解: 显然没有交叉的情况,因为如果交叉的话可能不是最优解. 然后考虑dp[i][j]表示第i个人拿了第j把钥匙,然后 dp[i][j]=max(val(i,j),min(dp[i-1][i-1~j]))   val(i,j)表示第i个人拿