C++深信服笔试

中位数 #include<bits/stdc++.h> using namespace std; priority_queue<int,vector<int>,less<int>> L; priority_queue<int,vector<int>,greater<int>> R; void up(int x) {     if(L.size()<=R.size())     {        if(!R.empty()&&R.top()<x)         {             L.push(R.top());R.pop();             R.push(x);         }         else L.push(x);     }     else{         if(!L.empty()&&L.top()>x)         {             R.push(L.top());L.pop();             L.push(x);         }         else R.push(x);       } } int main() {     int n,t;     while(cin>>n){         for(int i=1;i<=n;i++)         {             cin>>t;             up(t);         }         while(L.size()>R.size()+1)         {             R.push(L.top());             L.pop();         }         while(L.size()<R.size()+1)         {             L.push(R.top());             R.pop();         }         cout<<L.top()<<endl;     }     return 0; }



切蛋糕
#include<bits/stdc++.h> using namespace std; int main() {     int t;     cin>>t;     while(t--){         long long x,n;         cin>>x>>n;         long long s = 0;         if(n>=x){             s = max(s,x*(n-x));         }         for(int i=1;i<=n;i++){             s = max(s,i*(n-2*i));         }         cout<<s<<endl;     }     return 0; }

剩下两个板子题没搓出来,没板战士等于辣鸡


#深信服##笔试题目#
全部评论
深信服大佬
点赞 回复 分享
发布于 2018-11-01 16:31
可以发个大致题目是啥吗
点赞 回复 分享
发布于 2018-09-15 17:27

相关推荐

不愿透露姓名的神秘牛友
昨天 11:29
已编辑
斯卡蒂味的鱼汤:知道你不会来数马,就不捞你😂最近数马疯狂扩招,招聘要求挺低的,你能力肯定够,应该就是因为太强了,知道你不会来才不捞你
投递腾讯云智研发等公司10个岗位
点赞 评论 收藏
分享
评论
2
23
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务