int n,t;
cin>>n;
set s;
for(int i = 0; i<n; i++)
{
cin>>t;
set::iterator it = s.lower_bound(t);
if(it!=s.end())
{
s.insert(t);
s.erase(*it);//或者s.erase(it)也行
}
else s.insert(t);
}
cout<<s.size();
}
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
set s;
int n;
cin>>n;
for(int i=0;i<n;i++){
int a;
cin>>a;
if(s.upper_bound(a) != s.end()){
s.erase(s.upper_bound(a));
}
s.insert(a);
}
cout<<s.size()<<endl;
return 0;
}
#include
#include
#include
using namespace std;
bool cmp(float x, float y) {
if (x > y)
return true;
return false;
}
int main() {
int N, K, M;
cin >> N >> K >> M;
float* students = new float[N];
for (int i = 0; i < N; i++) {
float max = -1,min=101;
float sum = 0;
for (int j = 0; j < K; j++) {
int grade;
cin >> grade;
sum += grade;
if (max < grade)
max = grade;
if (min > grade)
min = grade;
}
sum = sum - max - min;
sum = sum / (K - 2);
students[i] = sum;
}
sort(students, students + N,cmp);
printf(“%.3f”, students[M - 1]);
for (int i = 1; i < M; i++) {
printf(" %.3f", students[M-i-1]);
}
cout << endl;
delete[]students;
return 0;
}
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<malloc.h>
typedef struct Node{
double score;
}Node;
void shellinsert(Node *a,int n,int dk){//希尔插入函数
Node temp;
for(int i=dk;i<n;i+=dk){
if(a[i].score<a[i-dk].score){
temp=a[i];
int j;
for(j=i-dk;j>=0&&a[j].score>temp.score;j-=dk){
a[j+dk]=a[j];
}
a[j+dk]=temp;
}
}
}
void shellsort(Node *a,int n){//希尔排序函数
int dk[12]={5000,2500,1000,500,250,125,75,30,15,8,4,1};
for(int i=0;i<12;i++){
shellinsert(a,n,dk[i]);
}
}
int main(){
int n,k,m;
scanf(“%d %d %d”,&n,&k,&m);
Node a[n];
for(int i=0;i<n;i++){
int e;
int max=-999;//记录max
int min=999;//记录min
int sum=0;//记录和
for(int j=0;j<k;j++){
scanf(“%d”,&e);
sum+=e;
if(e>max)max=e;
if(e<min)min=e;
}
a[i].score=(sum-max-min)*1.0/(k-2);//去掉max,min
}
shellsort(a,n);
if(m>n)m=n;//注意m>n时让m等与n
int flag=0;
for(int i=n-m;i<n;i++){
if(flag==1){
printf(" %.3f",a[i].score);
}else{
flag=1;
printf(“%.3f”,a[i].score);
}
}
printf(“\n”);
return 0;
}
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
int n;
struct people{
int sex,father=-1,mother=-1;
}peo[N];
bool st[N],flag;
void dfs(int cur,int generation)
{
if(cur==-1) return;
if(generation>5) return;
st[cur]=1;
dfs(peo[cur].father,generation+1);
dfs(peo[cur].mother,generation+1);
}
void finddfs(int cur,int generation)
{
if(cur==-1) return;
if(generation>5) return;
if(st[cur]) flag=true;
finddfs(peo[cur].father,generation+1);
finddfs(peo[cur].mother,generation+1);
}
int main()
{
cin>>n;
int id,father,mother;
string sex;
for(int i=0;i<n;i++)
{
cin>>id>>sex;
if(sex==“M”) peo[id].sex=1;
else peo[id].sex=0;
cin>>peo[id].father>>peo[id].mother;
peo[peo[id].father].sex=1;
peo[peo[id].mother].sex=0;
}
cin>>n;
int a,b;
for(int i=0;i<n;i++)
{
cin>>a>>b;
if(peo[a].sex==peo[b].sex) puts(“Never Mind”);
else{
memset(st,false,sizeof st);
dfs(a,1);
flag=false;
finddfs(b,1);
if(flag) puts(“No”);
else puts(“Yes”);
}
}
return 0;
}
#include
#include
#include
#include
using namespace std;
int result;
struct Person {
int sex;
vector parent;
};
map<int, Person> people;
void judge(int start, int end, int len) {
if (start == end)
result = 1;
if (len<4)
for (auto &i: people[start].parent)
for (auto &j: people[end].parent)
judge(i, j, len + 1);
}
int main() {
int n, m, id, father, mother;
char sex;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> id >> sex >> father >> mother;
people[id].sex=sex==‘M’ ? 1 : 0 ;
people[father].sex = 1;
if (father != -1)
people[id].parent.push_back(father);
if (mot
必看视频!获取2024年最新Java开发全套学习资料
her != -1)
people[id].parent.push_back(mother);
}
cin >> m;
for (int i = 0; i < m; i++) {
cin >> father >> mother;
if (people[father].sex == people[mother].sex)
cout << “Never Mind” << endl;
else {
result = 0;
judge(father, mother, 0);
cout << (result ? “No” : “Yes”) << endl;
}
}
return 0;
}
#include
#include
#include
#include
#include
using namespace std;
int main(){
int N,Sum,sum=0;
cin>>N;
vectorres;//把所有数据存储起来
for(int i=1;i<=N;i++){
int num;
cin>>num;
res.push_back(num);
}
sort(res.begin(),res.end());//进行排序 先排序后分类
for(int i=0;i<N/2;i++)//总数的一半代表Introverted的人数
sum+=res[i];//计算Introverted人的活跃度
Sum=accumulate(res.begin(),res.end(),0);//总的活跃度
cout<<"Outgoing #: "<<N-N/2<<endl;
cout<<"Introverted #: "<<N/2<<endl;
cout<<"Diff = "<<abs((Sum-sum)-sum);//总的活跃度-内向型=外向型 外向型-内向型的绝对值
return 0;
}
#include<stdio.h>
#include
#include
using namespace std;
int main()
{
int i,j,n,m,k,t,l,Min=0,Max=0;
priority_queue<int,vector,greater > q;
scanf(“%d”,&n);
for(i=0;i<n;i++)
{
scanf(“%d”,&l);
q.push(l);
}
for(i=0;i<n;i++)
{
int tmp=q.top();
//printf(“%lld\n”,tmp);
q.pop();
if(i<n/2)
{
最后
经过日积月累, 以下是小编归纳整理的深入了解Java虚拟机文档,希望可以帮助大家过关斩将顺利通过面试。
由于整个文档比较全面,内容比较多,篇幅不允许,下面以截图方式展示 。
由于篇幅限制,文档的详解资料太全面,细节内容太多,所以只把部分知识点截图出来粗略的介绍,每个小节点里面都有更细化的内容!
_queue<int,vector,greater > q;
scanf(“%d”,&n);
for(i=0;i<n;i++)
{
scanf(“%d”,&l);
q.push(l);
}
for(i=0;i<n;i++)
{
int tmp=q.top();
//printf(“%lld\n”,tmp);
q.pop();
if(i<n/2)
{
最后
经过日积月累, 以下是小编归纳整理的深入了解Java虚拟机文档,希望可以帮助大家过关斩将顺利通过面试。
由于整个文档比较全面,内容比较多,篇幅不允许,下面以截图方式展示 。
[外链图片转存中…(img-aHNKurec-1720153945523)]
[外链图片转存中…(img-zFiJZewk-1720153945524)]
[外链图片转存中…(img-qBTvPIcX-1720153945524)]
[外链图片转存中…(img-R2C5kpQs-1720153945525)]
[外链图片转存中…(img-dnXdh3Yc-1720153945525)]
[外链图片转存中…(img-WHX1cKSW-1720153945526)]
[外链图片转存中…(img-pIyUcEqu-1720153945526)]
由于篇幅限制,文档的详解资料太全面,细节内容太多,所以只把部分知识点截图出来粗略的介绍,每个小节点里面都有更细化的内容!