QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#730752 | #1173. Knowledge Is... | Luzexi | WA | 0ms | 3836kb | C++14 | 935b | 2024-11-09 21:26:51 | 2024-11-09 21:26:52 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x){
x = 0;
static char c;
static bool f;
c = getchar(), f = 0;
while(c < '0' || c > '9'){ if(c == '-')f = 1; c = getchar(); }
while('0' <= c && c <= '9')x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
x = f ? -x : x;
}
template <typename T,typename ...Types>
inline void read(T &x,Types &...y){
read(x);
read(y...);
}
const int N = 5e5 + 10;
using pii = pair<int,int>;
priority_queue<int,vector<int>,greater<int>> a,b;
pii s[N];
int n;
int main(){
read(n);
for(int i = 1;i<=n;++i)read(s[i].first,s[i].second);
sort(s+1,s+n+1);
int ans = 0;
for(int i = 1;i<=n;++i){
pii p = s[i];
int l = p.first, r = p.second;
if(a.size() && a.top() < l)a.pop(),++ans,b.push(r);
else if(b.size() && b.top() < r)a.push(b.top()),b.pop(),b.push(r);
else a.push(r);
}
printf("%d",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3836kb
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