QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#607386 | #1173. Knowledge Is... | zhulexuan | WA | 1ms | 5720kb | C++14 | 1.9kb | 2024-10-03 14:50:14 | 2024-10-03 14:50:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf INT_MAX
#define fr(i,l,r) for (i=(l); i<=(r); i++)
#define rfr(i,l,r) for (i=(l); i>=(r); i--)
template<typename T>inline void read(T &n){
T w=1; n=0; char ch=getchar();
while (!isdigit(ch) && ch!=EOF){ if (ch=='-') w=-1; ch=getchar(); }
while (isdigit(ch) && ch!=EOF){ n=(n<<3)+(n<<1)+(ch&15); ch=getchar(); }
n*=w;
}
template<typename T>inline void write(T x){
if (x==0){ putchar('0'); return ; }
T tmp;
if (x>0) tmp=x;
else tmp=-x;
if (x<0) putchar('-');
char F[105];
long long cnt=0;
while (tmp){
F[++cnt]=tmp%10+48;
tmp/=10;
}
while (cnt) putchar(F[cnt--]);
}
#define Min(x,y) x = min(x,y)
#define Max(x,y) x = max(x,y)
//基础配置=================================================================================
const ll N = 500005;
ll n,m,ans=0,x,y,l,r,s,z;
struct infor{
ll l,r;
};
infor a[N],b[N];
bool cmp1(infor x,infor y){
if (x.r==y.r) return x.l<y.l;
else return x.r<y.r;
}
bool cmp2(infor x,infor y){
if (x.l==y.l) return x.r>y.r;
else return x.l>y.l;
// return x.l>y.l;
}
inline bool check(ll s){
ll i,j;
for (ll i=1, j=s; i<=s; i++,j--)
if (b[j].l<=a[i].r) return false;
return true;
}
int main(){
// freopen("ex_interval2.in","r",stdin);
// freopen(".out","w",stdout);
ll i,j;
read(n);
fr(i,1,n) read(a[i].l), read(a[i].r), b[i] = a[i];
sort(a+1,a+1+n,cmp1);
sort(b+1,b+1+n,cmp2);
// printf("\n a :\n");
// fr(i,1,n) printf("%lld : %lld ~ %lld\n",i,a[i].l,a[i].r);
// printf("\n b :\n");
// fr(i,1,n) printf("%lld : %lld ~ %lld\n",i,b[i].l,b[i].r);
ll l = 0, r = n/2;
while (l<=r){
ll mid = (l+r)>>1;
if (check(mid)) l = mid+1;
else r = mid-1;
}
write(r);
return 0;
}
//g++ a.cpp -o a -Wall -Wl,--stack=512000000 -std=c++11 -O2
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5720kb
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