当前位置 : 主页 > 网页制作 > HTTP/TCP >

P1095-守望者的逃离

来源:互联网 收集:自由互联 发布时间:2021-06-16
1 #pragma GCC optimize("Ofast") 2 #include bits/stdc++.h 3 #define maxn 13003 4 #define _for(i,a,b) for(int i = (a);i b;i ++) 5 typedef long long ll; 6 using namespace std; 7 8 inline ll read() 9 { 10 ll ans = 0 ; 11 char ch = getchar(), la
 1 #pragma GCC optimize("Ofast")
 2 #include <bits/stdc++.h>
 3 #define maxn 13003
 4 #define _for(i,a,b) for(int i = (a);i < b;i ++)
 5 typedef long long ll;
 6 using namespace std;
 7 
 8 inline ll read()
 9 {
10     ll ans = 0;
11     char ch = getchar(), last =  ;
12     while(!isdigit(ch)) last = ch, ch = getchar();
13     while(isdigit(ch)) ans = (ans << 1) + (ans << 3) + ch - 0, ch = getchar();
14     if(last == -) ans = -ans;
15     return ans;
16 }
17 inline void write(ll x)
18 {
19     if(x < 0) x = -x, putchar(-);
20     if(x >= 10) write(x / 10);
21     putchar(x % 10 + 0);
22 }
23 int M,S,T;
24 int SS,TT;
25 int main()
26 {
27     M = read(),S = read(),T = read();
28     SS = S;TT = T;
29     int i;
30     for(i = 0;i < T;i ++)
31     {
32         if(S <= 0) break;
33         if(M >= 10)
34         {
35             M -= 10;
36             S -= 60;
37         }
38         else if(((T-i<=1||S<=17)&&M<10) || ((T-i<=2||S<=34)&&M<6)
39          || ((T-i<=3||S<=51)&&M<2) || ((T-i<=4||S<=68)&&M<2)
40          || ((T-i<=5||S<=85)&&M<2) || ((T-i<=6||S<=102)&&M<2)
41          || (S<=119&&M<2))
42             S -= 17;
43         else if(M >= 2)
44             M += 4;
45         else if(S >= 120 && T-i >= 7)
46         {
47             while(S >= 120 && T-i >= 7)
48             {
49                 i += 7;
50                 S -= 120;
51             }
52             i --;
53         }
54     }
55     if(S <= 0)
56         printf("Yes\n%d\n",i);
57     else
58         printf("No\n%d\n",SS-S);
59     return 0;
60 }

https://www.luogu.org/blog/Asurudo/solution-p1095

上一篇:LeetCode-数组专题
下一篇:转发和重定向
网友评论