编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#24476 #2036. 蓝桥杯 Accepted 100 263 ms 1212 K C++ 17 / 2.8 K 192024211724 2024-12-21 15:04:19
显示原始代码
#include <bits/stdc++.h>
#define ll long long


using namespace std;

const int inf = 0x3f3f3f3f;

const int maxn = 1e7 + 5;
int prime[maxn];
int isprime[maxn];
int tot = 0;
unordered_map<int, bool> mp;

ll mod = 1e9 + 7;

ll fun(ll res, ll k) { return 0; }

int getDigitSum(int x) {
    int res = 0;
    while (x) {
        res += x % 10;
        x /= 10;
    }
    return res;
}

void getPrime() {
    for (int i = 2; i < maxn; i++) {
        if (!isprime[i]) {
            prime[tot++] = i;
            mp[i] = true;
        }
        for (int j = 0; j < tot && i * prime[j] < maxn; j++) {
            isprime[i * prime[j]] = 1;
            if (i % prime[j] == 0)
                break;
        }
    }
}

bool cmp(pair<int, int> &a, pair<int, int> &b) {
    if (a.first == b.first)
        return a.second < b.second;
    return a.first < b.first;
}

bool strMax(string a, string b) {
    if (a.length() > b.length())
        return true;
    if (a.length() < b.length())
        return false;
    int m = a.length();
    for (int i = 0; i < m; i++) {
        if (a[i] > b[i])
            return true;
        if (a[i] < b[i])
            return false;
    }
    return true;
}

bool cmpStr(string &a, string &b) {
    if (strMax(a, b))
        return true;
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    /***
    int n;
    cin >> n;
    vector<int> b(n);
    vector<pair<int, int>> a(n);
    for(int i = 0; i < n; i ++){
        int x;
        cin >> x;
        b[i] = x;
        a[i] = make_pair(x, i);
    }
    sort(a.begin(), a.end(), cmp);
    //for(int i = 0; i < n; i ++) cout << a[i].first << " " << a[i].second << "\n";
    int ans = 0;
    int change = 0;
    priority_queue<int, vector<int>, greater<int>> heap;
    for(int i = 0; i < n; i ++){
            cout << change << "\n";
        while(!heap.empty() && heap.top() < i){
            heap.pop();
            change --;
        }
        //cout << a[i].second + change << " " << i << '\n';
        if(a[i].second + change > i){
            //cout << a[i].second + change << " " << i << '\n';
            //cout << "\n";
            ans += a[i].second + change - i;
            heap.push(a[i].second + change);
            change ++;
        }
    }
    cout << ans << "\n";
    ***/
    ll n, k, y;
    cin >> n >> k >> y;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.rbegin(), a.rend());
    if (a[0] < 0 && a[0] < y) {
        cout << "No\n";
    } else {
        bool ok = false;
        ll res = 0;
        for (int i = 0; i < k; i++) {
            if (res >= y) {
                ok = true;
                break;
            }
            res += a[i];
        }
        if (res >= y)
            ok = true;
        if (ok)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    return 0;
}
子任务 #1
Accepted
得分:100
测试点 #1
Accepted
得分:100
用时:4 ms
内存:296 KiB

输入文件(0.in

3 2 10
4 0 6

答案文件(0.out

Yes

用户输出

Yes

Special Judge 信息

Accepted!

系统信息

Exited with return code 0
测试点 #2
Accepted
得分:100
用时:4 ms
内存:340 KiB

输入文件(1.in

3 2 10
4 8 6

答案文件(1.out

Yes

用户输出

Yes

Special Judge 信息

Accepted!

系统信息

Exited with return code 0
测试点 #3
Accepted
得分:100
用时:4 ms
内存:328 KiB

输入文件(2.in

3 2 10
4 0 5

答案文件(2.out

No

用户输出

No

Special Judge 信息

Accepted!

系统信息

Exited with return code 0
测试点 #4
Accepted
得分:100
用时:4 ms
内存:324 KiB

输入文件(3.in

3 1 10
4 8 6

答案文件(3.out

No

用户输出

No

Special Judge 信息

Accepted!

系统信息

Exited with return code 0
测试点 #5
Accepted
得分:100
用时:4 ms
内存:412 KiB

输入文件(4.in

3 2 -1
-1 -1 -100000000000

答案文件(4.out

Yes

用户输出

Yes

Special Judge 信息

Accepted!

系统信息

Exited with return code 0
测试点 #6
Accepted
得分:100
用时:4 ms
内存:324 KiB

输入文件(5.in

3 2 10
1 1 1

答案文件(5.out

No

用户输出

No

Special Judge 信息

Accepted!

系统信息

Exited with return code 0
测试点 #7
Accepted
得分:100
用时:4 ms
内存:324 KiB

输入文件(6.in

10 10 1000000000000000000
1000000000000000000 1000000000000000000 1000000000000000000 1000000000000
<126 bytes omitted>

答案文件(6.out

Yes

用户输出

Yes

Special Judge 信息

Accepted!

系统信息

Exited with return code 0
测试点 #8
Accepted
得分:100
用时:24 ms
内存:1180 KiB

输入文件(7.in

100000 100000 -1000000000000000000
999999999999999999 999999999999999998 999999999999999997 9999999
<1899937 bytes omitted>

答案文件(7.out

Yes

用户输出

Yes

Special Judge 信息

Accepted!

系统信息

Exited with return code 0
测试点 #9
Accepted
得分:100
用时:26 ms
内存:1212 KiB

输入文件(8.in

100000 100000 1000000000000000000
999999999999999999 999999999999999998 999999999999999997 99999999
<1899936 bytes omitted>

答案文件(8.out

Yes

用户输出

Yes

Special Judge 信息

Accepted!

系统信息

Exited with return code 0
测试点 #10
Accepted
得分:100
用时:31 ms
内存:1092 KiB

输入文件(9.in

100000 17500 -902453319573581986
220568132319119820 -606006309927785772 221817482777749182 -7792985
<1938812 bytes omitted>

答案文件(9.out

Yes

用户输出

Yes

Special Judge 信息

Accepted!

系统信息

Exited with return code 0
测试点 #11
Accepted
得分:100
用时:30 ms
内存:1112 KiB

输入文件(10.in

100000 59746 -894671582265816580
-492208032683319612 -226878609136481601 -306800644502256962 374974
<1938701 bytes omitted>

答案文件(10.out

Yes

用户输出

Yes

Special Judge 信息

Accepted!

系统信息

Exited with return code 0
测试点 #12
Accepted
得分:100
用时:30 ms
内存:1088 KiB

输入文件(11.in

100000 71769 -777852166203488646
-326987560522471833 -887811703858463716 -665171390765756268 -50175
<1988850 bytes omitted>

答案文件(11.out

Yes

用户输出

Yes

Special Judge 信息

Accepted!

系统信息

Exited with return code 0
测试点 #13
Accepted
得分:100
用时:30 ms
内存:1092 KiB

输入文件(12.in

100000 75403 -224443883563768932
-965803835834204200 -547463733508387122 -215638566770371317 -99723
<1988848 bytes omitted>

答案文件(12.out

Yes

用户输出

Yes

Special Judge 信息

Accepted!

系统信息

Exited with return code 0
测试点 #14
Accepted
得分:100
用时:30 ms
内存:1212 KiB

输入文件(13.in

100000 59735 -908335187949265337
-244688300138684379 -860666135504880809 -159325669831553934 -60417
<1988874 bytes omitted>

答案文件(13.out

Yes

用户输出

Yes

Special Judge 信息

Accepted!

系统信息

Exited with return code 0
测试点 #15
Accepted
得分:100
用时:30 ms
内存:1180 KiB

输入文件(14.in

100000 80663 -828251309966719903
-427151939844345409 -795520490352793691 -364901579229946334 -92688
<1988882 bytes omitted>

答案文件(14.out

Yes

用户输出

Yes

Special Judge 信息

Accepted!

系统信息

Exited with return code 0
测试点 #16
Accepted
得分:100
用时:4 ms
内存:324 KiB

输入文件(15.in

10 10 1000000000000000000
-1000000000000000000 -1000000000000000000 -1000000000000000000 -100000000
<136 bytes omitted>

答案文件(15.out

No

用户输出

No

Special Judge 信息

Accepted!

系统信息

Exited with return code 0