2 条题解

  • 0
    @ 2025-10-28 0:19:45
    //如果x>y,那么所有门一定会被破坏掉,
    //如果x<=y,那么应该尽可能破坏更多的门,如果门被修复,则无法被破坏,而被破坏的门又无法被修复,所以修复者会把破坏者能破坏的门修复一下
    //
    //如果门的耐久<x,那么破坏者就有机会将门破坏掉,同时也是修复者修复的对象。
    //
    /*
     * Create By leo
     * Gods and Buddhas, bless me to rank higher!
     * Date: 2025年10月28日 - 0:06:32
     */
    #include<bits/stdc++.h>
    using namespace std;
    const int N = 2e5 + 12;
    
    
    int a[N];
    
    void solve() {
        int n,x,y;cin >> n >> x >> y;
        for (int i = 1;i <= n;i++)cin >>a[i];
    
        if (x > y) {
            cout << n << '\n';
            return ;
        }
        int ans = 0;
        for (int i = 1;i <= n;i++) {
            if (a[i] <= x)ans ++;
        }
        cout << ceil(1.0 * ans / 2) << '\n';
    }
    
    int main() {
        int t = 1;
        //cin >> t;
        while (t--) {
            solve();
        }
        return 0;
    }
    
    • 0
      @ 2024-12-26 17:11:19

      C :

      #include<stdio.h>
      int main()
      {
      	int n,x,y;
      	int a[99];
      
      	scanf("%d%d%d",&n,&x,&y);
      
      	for(int i=0;i<n;i++) scanf("%d",&a[i]);
      
      	if(x>y)
      	{
      	    printf("%d",n);
      		return 0;
      	}
      	else
      	{
      	    int cnt=0;
      		for(int i=0;i<n;i++)
      		{
      		    if(a[i]<=x) cnt++;
      		}
      		
      		if(cnt%2)
      			printf("%d",cnt/2+1);
      		else
      			printf("%d",cnt/2);
      	}
      
          return 0;
      }
      

      C++ :

      #include <bits/stdc++.h>
      #define int long long
      using namespace std;
      const int N=1e6+10;
      typedef pair<int,int> PII;
      typedef priority_queue<int , vector<int>, greater<int>> minqueue;  //从小到大 queue
      typedef priority_queue<int, vector<int>, less<int>> maxqueue;      //从大到小 queue
      
      int gcd(int a, int b){  //最大公因数 
          return b ? gcd(b, a % b) : a;
      }
      
      int lcm(int a, int b){ //最小公倍数 
          return a * b / __gcd(a, b);
      }
      
      int qmi(int base, int power, int p)  //快速幂求余 
      {
      	int result = 1;   
      	while (power > 0)           
      	{
      		if (power & 1)         							
      			result = result * base % p;   
      		base = base * base % p ;       						
      		power >>= 1;         						
      	}
      	return result % p;       
      }
      
      int a[N];
      
      void solve()
      {
      	int n,x,y;
      	cin>>n>>x>>y;
      	int cnt=0;
      	for(int i=0;i<n;i++){
      		cin>>a[i];
      		if(a[i]<=x) cnt++;
      	}
      	int ans=0;
      	if(x>y){
      		cout<<n<<'\n';
      		return;
      	}
      	else{
      		if(cnt%2==0) ans=cnt/2;
      		else ans=cnt/2+1;
      	}
      	cout<<ans<<'\n';
      }
      
      signed main()
      {
      	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
      	int t;
      	t=1;
      	while(t--)     
      	{
      		solve();
      	}
      	return 0;
      }
      
      • 1

      信息

      ID
      707
      时间
      1000ms
      内存
      128MiB
      难度
      7
      标签
      提交数
      43
      已通过
      9
      上传者