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-09-15 17:27
深信服大佬
点赞 回复
分享
发布于 2018-11-01 16:31
淘天集团
校招火热招聘中
官网直投

相关推荐

2 22 评论
分享
牛客网
牛客企业服务