WA=WAr
AC=ACcident
RE=REfuse
CE=CEll
WHK=Wonderful Homework Killer
不走寻常路做法,样例过了,但全是Wonderful Answer。
#include<bits/stdc++.h>
using namespace std;
int main(){
long long q,c,x,a[10001]={},cnt=-1,f=0;
bool o=0;
cin >> q;
for(long long i=1;i<=q;i++){
cin >> c >> x;
if(c==5){
a[++cnt] = x;
}
else{
f = 0;
sort(a,a+cnt);
if(c==1){
while(a[f]!=x){
f++;
}
cout << f+1 << endl;
}
else if(c==2){
cout << a[x-1] << endl;
}
else if(c==3){
while(a[f]<x){
f++;
if(f>cnt){
o=1;
break;
}
}
if(o==1){
o=0;
cout << "-2147483647" << endl;
}
else{
cout << a[f-1] << endl;
}
}
else{
while(a[f]<=x){
f++;
if(f>cnt){
o=1;
break;
}
}
if(o==1){
o=0;
cout << "2147483647" << endl;
}
else{
cout << a[f] << endl;
}
}
}
}
return 0;
}
Who can help me?