QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#393992 | #2536. Akcija | lfxxx# | 0 | 98ms | 4796kb | C++17 | 2.2kb | 2024-04-19 20:09:41 | 2024-07-04 03:36:41 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
bool be;
constexpr int N = 2005;
int n, k, ct, up[N], t[N];
struct Node {
int w, d;
}a[N];
vector<int>v[N];
set<vector<int>>se;
struct node {
ll val;
vector<int>ve;
node()
{
val = 0;
}
inline void push(int x)
{
ve.emplace_back(x);
val += a[x].w;
}
inline bool operator < (node a) const {
return val > a.val;
}
};
priority_queue<node>q;
void dfs(int u, int left, node c)
{
if (n - u + 1 < left) return;
if (u > n) {
if (se.emplace(c.ve).second) {
q.emplace(c);
// cerr << c.val << '\n';
// for (int x : c.ve) cerr << x << ' ';
// cerr << '\n';
}
return;
}
dfs(u + 1, left, c);
if (left && up[a[u].d]) {
c.push(u);
--up[a[u].d];
dfs(u + 1, left - 1, c);
++up[a[u].d];
}
}
void init(int lim)
{
while (!q.empty()) q.pop();
dfs(1, lim, node());
}
bool en;
int main() {
cerr << (&be - &en) / 1024.0 / 1024 << " MB\n--------------------------------" << endl;
#ifdef IAKIOI
freopen("in.in", "r", stdin);
// freopen("out.out", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> k;
for (int i = 1; i <= n; ++i) {
cin >> a[i].w >> a[i].d;
}
sort(a + 1, a + 1 + n, [](Node a, Node b) {
if (a.d != b.d) return a.d < b.d;
return a.w < b.w;
});
for (int i = 1; i <= n; ++i) {
++t[a[i].d];
}
int tot = 0;
for (int i = 1; i <= n; ++i) {
++ct;
while (ct && up[i] < t[i]) {
--ct;
++up[i];
++tot;
}
}
for (int i = tot; i >= 0; --i) {
// cerr << "Round " << i << '\n';
init(i);
while (!q.empty()) {
node c = q.top();
q.pop();
cout << i << ' ' << c.val << '\n';
if (!--k) return 0;
for (int i = 0; i < c.ve.size(); ++i) {
if (((c.ve[i] + 1 == c.ve.size() && c.ve[i] < n) || (c.ve[i] + 1 < c.ve[i + 1])) && a[c.ve[i]].d == a[c.ve[i] + 1].d) {
c.val -= a[c.ve[i]].w;
++c.ve[i];
c.val += a[c.ve[i]].w;
if (se.emplace(c.ve).second) {
q.emplace(c);
}
c.val -= a[c.ve[i]].w;
--c.ve[i];
c.val += a[c.ve[i]].w;
}
}
}
}
return 0;
}
详细
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 0
Time Limit Exceeded
input:
1919 1 126746165 1373 126746165 1621 126746165 1157 126746165 1647 126746165 1046 126746165 1626 126746165 813 126746165 1197 126746165 1240 126746165 738 126746165 840 126746165 571 126746165 1712 126746165 109 126746165 1850 126746165 524 126746165 736 126746165 917 126746165 1520 126746165 1559 1...
output:
result:
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Time Limit Exceeded
Test #27:
score: 0
Time Limit Exceeded
input:
1919 2 126746165 1373 668827372 1621 842598033 1157 119717982 1647 527842278 1046 492815129 1626 917098873 813 346103003 1197 144760418 1240 339840086 738 518170881 840 527423104 571 783646464 1712 77685618 109 74284316 1850 300769843 524 944005181 736 969138120 917 789000286 1520 358649048 1559 189...
output:
result:
Subtask #4:
score: 0
Wrong Answer
Test #40:
score: 0
Wrong Answer
time: 4ms
memory: 4796kb
input:
19 1910 872059530 14 567896598 17 515371564 12 609933207 17 421749461 11 993851818 17 897732743 9 76274388 12 362276371 13 93554371 8 695969254 9 21709341 6 395396341 17 894018749 2 835539456 19 150700500 6 934168428 8 934249073 10 508532761 16
output:
18 9787132136 18 10171050747 18 10213087356 18 10385587613 18 10597005967 18 10769506224 18 10811542833 18 11195461444 17 8852883063 17 8852963708 17 8889399393 17 8893113387 17 8894919672 17 8895000317 17 8915072606 17 8931436002 17 8935149996 17 8951592680 17 8957109215 17 8993629289 17 9067419929...
result:
wrong answer 2nd lines differ - expected: '18 9846734881', found: '18 10171050747'
Subtask #5:
score: 0
Wrong Answer
Test #53:
score: 0
Wrong Answer
time: 98ms
memory: 4424kb
input:
96 96 390531470 69 349016804 82 612244127 58 41258987 83 470944790 53 681046579 82 109569778 41 700928268 60 224279712 63 681889278 37 173204769 43 701269722 29 624757038 86 271969787 6 444924884 93 500697380 27 509702566 37 262449977 46 669488879 77 170692294 78 362932916 51 118514404 47 724509790 ...
output:
94 43256361993 94 43276402942 94 43866027675 94 44096130177 94 44116171126 94 44705795859 93 42258537798 93 42267276538 93 42270414161 93 42272038213 93 42278578747 93 42287317487 93 42290455110 93 42292079162 93 42310958201 93 42327465187 93 42330999150 93 42347506136 93 42351904072 93 42352930523 ...
result:
wrong answer 1st lines differ - expected: '94 42881894279', found: '94 43256361993'
Subtask #6:
score: 0
Skipped
Dependency #1:
0%