QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#724347 | #9470. Cats and Fish | supepapupu | AC ✓ | 0ms | 3808kb | C++20 | 1.2kb | 2024-11-08 12:16:58 | 2024-11-08 12:16:59 |
Judging History
answer
#include <bits/stdc++.h>
#define DEBUG
#ifdef DEBUG
#define debug(x) cerr << #x << ": " << (x) << endl
#define print(x) cerr << x << ' '
#define println(x) cerr << x << endl
#else
#define debug(x)
#define print(x)
#define println(x)
#endif
#define x first
#define y second
#define el '\n'
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int N = 3e5 + 10, INF = 0x3f3f3f3f, mod = 998244353;
void solve(int m, int n, int x) {
vector<int> c(n);
priority_queue<pii, vector<pii>, greater<pii>> Q;
for (int i = 0; i < n; ++i) cin >> c[i];
sort(c.begin(), c.end());
for (int i = 0; i < n; ++i)
if (Q.size() < m)
Q.emplace(c[i], c[i]);
int cnt = 0, cnt2 = 0;
while (Q.size()) {
auto[t, c] = Q.top(); Q.pop();
if (t <= x) ++cnt;
else ++cnt2;
if (t < x && cnt + cnt2 + Q.size() < m)
Q.emplace(t + c, c);
}
cout << m - cnt - cnt2 << ' ' << cnt2 << el;
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
// int tcase = 1;
// cin >> tcase;
int m, n, x;
while (cin >> m >> n >> x) solve(m, n, x);
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3808kb
input:
2 1 1 1 8 3 5 1 3 4 4 5 1 5 4 3 2 1
output:
1 0 0 1 0 3
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
1 1 10 1 14 3 10 1 40 50 8 2 7 12 13 1 1 1 2 12 2 11 8 3 2 2 12 24 1 562 8 232 17 26 800 12 77 32 11 2 562 8 1 17 26 800 12 77 32 11 1 3656 13 123 1887 26 800 12 77 32 11 1 77 32 77 32 155
output:
0 0 2 2 6 2 0 1 6 2 0 1 368 7 554 7 3484 12
result:
ok 9 lines