日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【CodeForces - 1102C 】Doors Breaking and Repairing (思维,简单博弈)

發布時間:2023/12/10 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【CodeForces - 1102C 】Doors Breaking and Repairing (思维,简单博弈) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題干:

You are policeman and you are playing a game with Slavik. The game is turn-based and each turn consists of two phases. During the first phase you make your move and during the second phase Slavik makes his move.

There are?nn?doors, the?ii-th door initially has durability equal to?aiai.

During your move you can try to break one of the doors. If you choose door?ii?and its current durability is?bibi?then you reduce its durability to?max(0,bi?x)max(0,bi?x)?(the value?xxis given).

During Slavik's move he tries to repair one of the doors. If he chooses door?ii?and its current durability is?bibi?then he increases its durability to?bi+ybi+y?(the value?yyis given).?Slavik cannot repair doors with current durability equal to?00.

The game lasts?1010010100?turns. If some player cannot make his move then he has to skip it.

Your goal is to maximize the number of doors with durability equal to?00?at the end of the game. You can assume that Slavik?wants to minimize?the number of such doors. What is the number of such doors in the end if you both play optimally?

Input

The first line of the input contains three integers?nn,?xx?and?yy?(1≤n≤1001≤n≤100,?1≤x,y≤1051≤x,y≤105) — the number of doors, value?xx?and value?yy, respectively.

The second line of the input contains?nn?integers?a1,a2,…,ana1,a2,…,an?(1≤ai≤1051≤ai≤105), where?aiaiis the initial durability of the?ii-th door.

Output

Print one integer — the number of doors with durability equal to?00?at the end of the game, if you and Slavik both play optimally.

Examples

Input

6 3 2 2 3 1 3 4 2

Output

6

Input

5 3 3 1 2 4 2 3

Output

2

Input

5 5 6 1 2 6 10 3

Output

2

Note

Clarifications about the optimal strategy will be ignored.

題目大意:

給你一個含有N個數的數組,每一個元素代表一個門的當前防御值

每一次你可以對門攻擊x個點數,而一個神仙可以對門進行y個點數的防御值提升(也可以高于初始防御值)。

當一次你對門的攻擊使這個門的防御值小于等于0的時候,這個門就壞掉了,神仙也沒法修復了。

問:當你和神仙都采取最優的策略的時候,你最多可以砸壞幾個門?

解題報告:

1.? ? x>y?,這樣的話,每一個門你都可以給砸壞。

2:當x<=y,這樣你的最優策略就是每一次去砸那些當前防御值比你的攻擊力x值小的門,一次就可以給砸壞,

而神仙的最優策略使去提升那些當前防御值比你的攻擊力x值小的門,一次來減少你的數量。當然,如果你砸那些不能一次砸壞的,他就來修復,所以這并不影響答案。

AC代碼:

#include<cstdio> #include<iostream> #include<algorithm> #include<queue> #include<map> #include<vector> #include<set> #include<string> #include<cmath> #include<cstring> #define ll long long #define pb push_back #define pm make_pair using namespace std; const int MAX = 2e5 + 5; int n,x,y,a[MAX],ans; int main() {cin>>n>>x>>y;ans=0;for(int i=1; i<=n; i++) {scanf("%d",&a[i]);if(a[i]<=x) ans++;}if(x>y) printf("%d\n",n);if(x<=y) {if(ans%2==0) printf("%d\n",ans/2);else printf("%d\n",ans/2+1);}return 0; }

?

總結

以上是生活随笔為你收集整理的【CodeForces - 1102C 】Doors Breaking and Repairing (思维,简单博弈)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。