QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#361068#8284. Cats and Fishpaoxiaomo#TL 0ms3880kbC++201.2kb2024-03-22 18:57:002024-03-22 18:57:01

Judging History

This is the latest submission verdict.

  • [2024-03-22 18:57:01]
  • Judged
  • Verdict: TL
  • Time: 0ms
  • Memory: 3880kb
  • [2024-03-22 18:57:00]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
struct cat
{
    int tim, speed;
    friend bool operator<(const cat &a, const cat &b)
    {
        if (a.tim == b.tim)
        {
            return a.speed > b.speed;
        }
        return a.tim > b.tim;
    }
};
void solve()
{
    int m, n, x;
    cin >> m >> n >> x;
    vector<int> t(n);
    priority_queue<cat> q;
    for (int i = 1; i <= n; i++)
    {
        cin >> t[i - 1];
    }
    sort(t.begin(), t.end());
    int n1 = 0, n2 = 0;
    for (int i = 1; i <= min(m, n); i++)
    {
        q.push({t[i - 1], t[i - 1]}), n2++;
    }

    m -= min(n, m);
    int fore = 0;
    for (int i = 1; i <= x; i++)
    {
        m -= fore;
        n2 += fore;
        fore = 0;
        while (q.top().tim <= i)
        {
            auto [tim, speed] = q.top();
            q.pop();
            n1++, n2--;
            if (m - fore != 0)
                q.push({tim + speed, speed}), fore++;
        }
    }
    cout << m << " " << n2 << endl;
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    // cin >> T;
    while (T--)
        solve();
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3880kb

input:

2 1 1
1

output:

1 0

result:

ok 2 number(s): "1 0"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

8 3 5
1 3 4

output:

0 1

result:

ok 2 number(s): "0 1"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

4 5 1
5 4 3 2 1

output:

0 3

result:

ok 2 number(s): "0 3"

Test #4:

score: -100
Time Limit Exceeded

input:

1 1 10
1

output:


result: