码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2019-04-19 00:52:51      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:cat   typedef   tor   problem   ORC   ios   return   代码   枚举   

链接: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让我看到我的实力有所下降,还有一个月就要校赛了,要把状态拉回来,基础要打牢,也要学新东西

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

标签:cat   typedef   tor   problem   ORC   ios   return   代码   枚举   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!