QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#282325#1173. Knowledge Is...ChendaqianWA 0ms3576kbC++141.2kb2023-12-11 19:13:032023-12-11 19:13:04

Judging History

你现在查看的是最新测评结果

  • [2023-12-11 19:13:04]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3576kb
  • [2023-12-11 19:13:03]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<algorithm>
#include<cmath>
#include<queue>
#define ll long long
#define db double

using namespace std;
const db eps=1e-6;
const ll lnf=1e18;
const int inf=0x3f3f3f3f;
ll read() {
	ll o=0,w=1;char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1;c=getchar();}
	while(c>='0'&&c<='9') {o=o*10+c-'0';c=getchar();}
	return o*w;
}

void DEBUG(string TIPS,auto *BG,auto *ED) {
	cout<<"\ndebug "<<TIPS<<" :\n";
	for(auto *it=BG;it<ED;*it++) printf("%d : %d\n",it-BG,*it);
	cout<<"\n";
}

namespace dada {

const int N=5e5+10;
int n,ans;
struct line {
	int l,r;
};
line d[N];
priority_queue<int,vector<int>,greater<int> > q1,q2;
int Main() {
	n=read();
	for(int i=1;i<=n;i++) {
		d[i].l=read();d[i].r=read();
	}
	sort(d+1,d+1+n,[&](line x,line y) {
		return x.l<y.l;
	});
	for(int i=1;i<=n;i++) {
		if(q1.empty()||q1.top()>d[i].l) {
			if(!q2.empty()&&q2.top()<d[i].r) {
				q1.push(q2.top());
				q2.pop();
				q2.push(d[i].r);
			} else {
				q1.push(d[i].r);
			}
		} else {
			q1.pop();
			q2.push(d[i].r);
		}
	}
	cout<<q2.size();
	return 0;
}
}
int main() {
	int T=1;
	while(T--) {dada::Main();}
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3576kb

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