QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#282161 | #1173. Knowledge Is... | K8He | WA | 0ms | 3616kb | C++14 | 1.4kb | 2023-12-11 15:26:02 | 2023-12-11 15:26:02 |
Judging History
answer
#include <bits/stdc++.h>
#define _for(i, a, b) for (int i = a; i <= b; ++i)
#define for_(i, a, b) for (int i = a; i >= b; --i)
#define far(i, vec) for (auto i : vec)
#define bdmd int mid = (l + r) >> 1
typedef long double ldb;
typedef long long ll;
typedef double db;
typedef std::pair <int, int> pii;
typedef std::pair <ll, ll> pll;
namespace IO {
int rnt () {
int x = 0, w = 1; char c = getchar ();
while (!isdigit (c)) { if (c == '-') w = -1; c = getchar (); }
while (isdigit (c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar ();
return x * w;
}
} // namespace IO
const int N = 5e5 + 10, P = 998244353;
namespace SOLVE {
using namespace IO;
int n, ans;
pii rg[N];
void In () {
n = rnt ();
_for (i, 1, n) rg[i].first = rnt (), rg[i].second = rnt ();
return;
}
void Solve () {
std::sort (rg + 1, rg + n + 1);
std::priority_queue <int, std::vector <int>, std::greater <int> > q[2];
_for (i, 1, n) {
if (!q[0].empty () && q[0].top () < rg[i].first)
++ans, q[1].push (rg[i].second), q[0].pop ();
else if (!q[1].empty ())
q[0].push (q[1].top ()), q[1].pop (), q[1].push (rg[i].second);
else
q[0].push (rg[i].second);
// std::cerr << i << " " << rg[i].first << " " << rg[i].second << " " << q.top () << std::endl;
}
return;
}
void Out () {
printf ("%d\n", ans);
return;
}
}
int main () {
SOLVE::In ();
SOLVE::Solve ();
SOLVE::Out ();
return 0;
} /*
*/
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3616kb
input:
7 5 9 10 7 9 3 4 9 10 2 6 8 9 5 8
output:
3
result:
wrong output format Unexpected end of file - int32 expected