QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#361068 | #8284. Cats and Fish | paoxiaomo# | TL | 0ms | 3880kb | C++20 | 1.2kb | 2024-03-22 18:57:00 | 2024-03-22 18:57:01 |
Judging History
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();
}
Details
Tip: Click on the bar to expand more detailed information
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