解题报告 —— cf1013div3

赛时四题,不解释,自己看

A:

#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int cnt[10]; 

void solve(){
    memset(cnt, 0, sizeof cnt);
    int n; cin >> n;
    vector<int> a(n+1);
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++){
        cnt[a[i]]++;
        //cout << a[i] << " "<< cnt[a[i]] << '\n';
        if(cnt[0] >= 3 && cnt[1] >= 1 && cnt[2] >= 2 && cnt[3] >= 1 && cnt[5] >= 1){
            cout << i << '\n';
            return;
        }
    }

    cout << 0 << '\n';
}

int main(){
    int t; cin >> t; while(t--)
    solve();return 0;
}

B:

/*
就是没有技术的贪心模拟
*/
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, inf = 0x3f3f3f3f;
int a[N];

bool cmp(int x, int y){
    return x > y;
}

void solve(){
    memset(a, 0, sizeof a);
    int n, x, j; cin >> n >> x;
    for(int i = 1; i <= n; i++) cin >> a[i];
    // max(len * min >= x)
    sort(a + 1, a + n + 1, cmp);
    int ans = 0, len = 1, last = 0;
    for(int i = 1; i <= n; i++){
        if(len * a[i] >= x){
            ans++;
            len = 0;
        }
        len++;
    }
    cout << ans << '\n';
}

int main(){
    int t; cin >> t; while(t--)
    solve();return 0;
}

C:

/*
7
1 2 3 4 5 6 7
6 1 3 5 7 2 4 
*/
#include <bits/stdc++.h>

using namespace std;
const int N = 2e5 + 10;

void solve(){
    int n; cin >> n;
    if(n % 2 == 0){
        cout << -1 << '\n';
        return;
    }
    vector<int> num;
    for(int i = 3; i <= n; i++){
        if(i % 2) num.push_back(i);
    }

    for(int i = 2; i < n - 1; i++){
        if(i % 2 == 0) num.push_back(i);
    }

    if(n == 1){
        cout << 1 << '\n';
    }
    else if(n < 5){
        cout << "1 3 2" << '\n';
    }else{
        cout << n - 1 << ' ' << 1 << ' ';
        for(auto x : num){
            cout << x << ' ';
        }
        cout << '\n';
    }
}

int main(){
    int t; cin >> t; while(t--)
    solve();return 0;
}

D

/*
最大值最小化
ll
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m, k;

bool check(ll x){
    ll len = x + 1;
    ll num = m/len; 
    ll le = m % len;
    ll tot = (num * x + le) * n;
    return tot >= k;
}

void solve(){
    cin >> n >> m >> k;
    ll l = 0, r = m;
    while(l < r){
        ll mid = (r + l) >> 1;
        if(check(mid)) r = mid;
        else l = mid + 1;
    }
    cout << l << '\n';
}

int main(){
    int t; cin >> t; while(t--)
    solve();return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值