QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#774134 | #9786. Magical Bags | ucup-team4474# | WA | 1ms | 3936kb | C++20 | 1.1kb | 2024-11-23 11:58:09 | 2024-11-23 11:58:09 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using i128 = __int128_t;
bool Memory_begin;
bool Memory_end;
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cerr << (&Memory_end - &Memory_begin) / 1048576.0 << "MB" << '\n';
int n;
cin >> n;
vector<pair<int, int>> a(n);
for (int i = 0, x, y; i < n; i++)
{
cin >> x;
a[i] = {1000000000, 1};
while (x--)
{
cin >> y;
a[i].first = min(a[i].first, y);
a[i].second = max(a[i].second, y);
}
}
int ans = n * 2;
priority_queue<pair<int, int>> que;
for (int i = 0; i < n; i++)
que.push({a[i].second, i});
while (!que.empty())
{
int mi = a[que.top().second].first;
while (!que.empty() and que.top().first >= mi)
{
int id = que.top().second;
que.pop();
mi = min(mi, a[id].first);
}
ans--;
}
cout << ans << '\n';
}
/*
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3848kb
input:
4 3 4 7 10 2 1 9 4 11 2 8 14 3 6 12 13
output:
7
result:
ok 1 number(s): "7"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3936kb
input:
4 1 1 1 2 1 3 1 4
output:
4
result:
ok 1 number(s): "4"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3748kb
input:
4 3 4 7 10 2 1 9 4 11 2 8 14 3 6 12 13
output:
7
result:
ok 1 number(s): "7"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
4 1 1 1 2 1 3 1 4
output:
4
result:
ok 1 number(s): "4"
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3716kb
input:
100 4 372861091 407948190 424244630 359746969 6 568180757 527358812 494745349 665803213 674832670 586694351 4 696340797 775899164 919971335 716827187 4 123145962 344250363 122030550 251739234 4 342654413 368648894 150539766 255189030 1 194505887 3 755984448 736803561 745474041 4 709314938 498953418 ...
output:
198
result:
wrong answer 1st numbers differ - expected: '177', found: '198'