acgo题库
  • 首页
  • 题库
  • 题单
  • 竞赛
  • 讨论
  • 排行
  • 备赛专区

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
登录
注册
题目详情题解(0)讨论(0)提交记录(0)
  • 终于AC了!

    userId_undefined

    man(但圣蛋)

    秩序白银
    23阅读
    0回复
    1点赞
  • 123

    #include<bits/stdc++.h> using namespace std; int n,m; struct node{ int b,c; }; bool cmp(node x,node y){ if(x.cy.c){ return x.b<y.b; }else if(x.c!=y.c){ return x.c<y.c; } } int main(){ cin>>n>>m; node man[n+5]; if(m0){ cout<<0; return 0; }else if(m==1){ int x; cin>>x; cout<<x; return 0; } for(int i=1;i<=m;i++){ cin>>man[i].b; man[i].c=abs(man[i].b-n); } sort(man+1,man+m+1,cmp); cout<<man[1].b; return 0; }

    userId_undefined

    186****6957

    倔强青铜
    8阅读
    0回复
    0点赞
首页