P1095-守望者的逃离

Posted asurudo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了P1095-守望者的逃离相关的知识,希望对你有一定的参考价值。

 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

以上是关于P1095-守望者的逃离的主要内容,如果未能解决你的问题,请参考以下文章

洛谷P1095·贪心·动态规划守望者的逃离

P1095 守望者的逃离

洛谷 P1095 守望者的逃离

洛谷——P1095 守望者的逃离

CODE[VS] 1144 守望者的逃离 || P1095 守望者的逃离

P1095 守望者的逃离