QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#608345 | #7689. Flipping Cards | MENDAX | WA | 2ms | 7816kb | C++14 | 1.6kb | 2024-10-03 20:56:27 | 2024-10-03 20:56:27 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define x first
#define y second
const int N=5e5+5,mod=1e9+7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int qmi(int a,int k){
int res=1;
while(k){
if(k&1) res=res*a%mod;
a=a*a%mod;
k>>=1;
}
return res;
}
typedef pair<int,int> PII;
int a[N],b[N],n,c[N];
//
//bool check(int x){//先看看有多少个数大于等于x的
// int pp=0;//是需要减还是需要加
// for(int i=1;i<=n;i++){
// if(a[i]<=x) pp++;
// }
//// cout<<pp<<" "<<x<<endl;
// //先看看x是不是中位数先
// if(c[(n+1)/2]==x) return true;
// if(pp<(n+1)/2){//那么就需要更多小于等于x的数量
// int res=0,mx=0;
// for(int i=1;i<=n;i++){
// int val=0;
// if(a[i]<=x) val--;
// if(b[i]<=x) val++;
// res+=val;
// if(res<0) res=0;
// mx=max(mx,res);
// }
// if(mx+pp>=(n+1)/2) return true;
// return false;
// }
// else {//看看大于等于x的数的数量有多少先
// pp=0;
// for(int i=1;i<=n;i++){
// if(a[i]>=x) pp++;
// }
// int res=0,mx=0;
// for(int i=1;i<=n;i++){
// int val=0;
// if(a[i]>=x) val--;
// if(b[i]>=x) val++;
// res+=val;
// if(res<0) res=0;
// mx=max(mx,res);
// }
// if(mx+pp>=(n+1)/2) return true;
// return false;
// }
//}
void slove(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i]>>b[i];
c[i]=max(a[i],b[i]);
}
sort(c+1,c+1+n);
cout<<c[(n+1)/2]<<endl;
}
signed main(){
ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
int T=1;
while(T--) slove();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 7772kb
input:
5 3 6 5 2 4 7 6 4 2 8
output:
6
result:
ok 1 number(s): "6"
Test #2:
score: 0
Accepted
time: 2ms
memory: 7680kb
input:
1 2 1
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: 0
Accepted
time: 2ms
memory: 7816kb
input:
1 212055293 384338286
output:
384338286
result:
ok 1 number(s): "384338286"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 7688kb
input:
99 749159996 323524232 125448341 365892333 481980673 143665393 394405973 44741918 687549448 513811513 287088118 385131171 11865696 666468353 449920567 373650719 671547289 116780561 41003675 671513243 351534153 507850962 374160874 985661954 222519431 600582098 987220654 704142246 856147059 37783620 1...
output:
720146033
result:
wrong answer 1st numbers differ - expected: '528957505', found: '720146033'