网易互联网2015 在线笔试(2)
来源:互联网 发布:淘宝韩国直邮鉴别真假 编辑:程序博客网 时间:2024/05/21 20:28
题目
题目大意叙述如下:
现有
设
设
主人公小明有权设立三分线位置,他想让
分析
此题要求
程序实现
#include <iostream>#include <cstdlib>#include <vector>#include <algorithm>using namespace std;int getCount(vector<int> &Bd, int m, int d){ int count = 0; for (int i = 0; i < m; i++) { if (Bd[i] < d) count++; } return count;}int maxScore(vector<int> &Ad, int n, vector<int> &Bd, int m){ //将AB两队的,投篮点排序 sort(Ad.begin(), Ad.end()); sort(Bd.begin(), Bd.end()); int max = 0 , dis = 0; for (int i = 0; i < n; i++) { //将三分点设置为当前 int d = Ad[i]; //求A队得分 int scoreA = 3 * (n - i) + 2 * i; //求B队得分 int num = getCount(Bd, m, d); int scoreB = 2 * num + 3 * (m - num); //求临时分差 int tmp = scoreA - scoreB; if (tmp > max) { max = tmp; dis = d; }//if } return max;}int main(){ int n, m,tmp; vector<int> Ad, Bd; cin >> n; for (int i = 0; i < n; i++) { cin >> tmp; Ad.push_back(tmp); } cin >> m; for (int i = 0; i < m; i++) { cin >> tmp; Bd.push_back(tmp); } cout << maxScore(Ad, n, Bd, m) << endl; system("pause"); return 0;}
0 0
- 网易互联网2015 在线笔试(2)
- 网易互联网2015 在线笔试(1)
- 网易游戏2015 在线笔试题(2)
- 2014年网易互联网在线笔试题一道
- 魔力手环-网易互联网2017在线笔试题目
- 网易互联网2017在线笔试题目-魔力手环
- 网易游戏2015 在线笔试题(5)
- 网易游戏2015 在线笔试题(1)
- 网易游戏2015 在线笔试题(4)
- 网易互联网笔试题(多年)
- 网易互联网笔试题(多年)
- 网易互联网产品笔试题
- 网易游戏2016在线笔试
- 网易2016在线笔试小结
- 2016年网易在线笔试
- [互联网面试笔试汇总C/C++-2] 网易有道-1
- [互联网面试笔试汇总C/C++-3] 网易有道-2
- 网易互联网产品类笔试题(数据挖掘岗位)
- iOS疯狂讲解之复杂对象的归档与反归档
- 欢迎使用CSDN-markdown编辑器
- Filter里面注入Service方法
- Remove Duplicates from Sorted List
- leetcode笔记:Remove Nth Node From End of List
- 网易互联网2015 在线笔试(2)
- andriod之自定义适配器与ListView的优化:
- studio删除无用的文件资源
- .net 的js选择方法
- 关于openssh连接时的尝试
- Object_C的setter、getter方法实现
- Session的生命周期
- html5之div,article,section区别与应用
- jquery未来元素绑定事件