关注
//弱鸡分享一下自己带吗 //第一题AC0.6 #include<iostream> #include<vector> #include<algorithm> using namespace std; struct po { int x; int y; }; bool comparex(po a, po b){ return a.x<b.x ? true : false; } int main(){ int N; cin >> N; vector<po> P; vector<int> yp; po temp; for (int i = 0; i<N; i++){ cin >> temp.x >> temp.y; P.push_back(temp); yp.push_back(temp.y); } sort(P.begin(), P.end(), comparex); sort(yp.begin(), yp.end()); vector<po> res; for (int i = 0; i<N - 1; i++){ vector<int>::iterator ty_it = find(yp.begin(), yp.end(), P[i].y); yp.erase(ty_it); if (P[i].y>yp[yp.size() - 1]) res.push_back(P[i]); } res.push_back(P[N - 1]); for (int i = 0; i<res.size(); i++) cout << res[i].x << " " << res[i].y << endl; system("pause"); return 0; } //第二题AC0.5 #include<iostream> #include<vector> using namespace std; int main(){ int n, temp; cin >> n; vector<int> num; for (int i = 0; i<n; i++){ cin >> temp; num.push_back(temp); } int res = 0, tempres, curto, curmin; for (int i = 0; i<n; i++){ curto = num[i]; curmin = num[i]; tempres = num[i] * num[i]; for (int j = i + 1; j<n; j++){ curmin = curmin<num[j] ? curmin : num[j]; curto += num[j]; tempres = tempres>curto*curmin ? tempres : curto*curmin; } res = res>tempres ? res : tempres; } cout << res << endl; system("pause"); return 0; }
查看原帖
点赞 评论
相关推荐
牛客热帖
更多
正在热议
更多
# 面试问题记录 #
40907次浏览 623人参与
# 工作一周年分享 #
16833次浏览 108人参与
# 京东TGT #
39800次浏览 160人参与
# 入职第五天,你被拉进了几个工作群 #
15697次浏览 80人参与
# 机械人,你的第一份感谢信是谁给的 #
24684次浏览 296人参与
# 假如我穿越到了妈妈的18岁 #
3565次浏览 37人参与
# 面试经验谈 #
27460次浏览 402人参与
# 面试吐槽bot #
8136次浏览 62人参与
# 视觉/交互/设计招聘信息汇总 #
12095次浏览 596人参与
# 职场捅娄子大赛 #
267706次浏览 2387人参与
# 国企vs私企,你更想去? #
214726次浏览 2040人参与
# 零跑求职进展汇总 #
3443次浏览 17人参与
# 请用你的专业向妈妈表白 #
7126次浏览 70人参与
# 上班苦还是上学苦呢? #
216267次浏览 1288人参与
# 腾讯云智研发工作体验 #
21327次浏览 142人参与
# 妈妈治愈了你哪些脆皮时刻 #
9396次浏览 131人参与
# 职场新人生存指南 #
342668次浏览 7333人参与
# 非技术er求职现状 #
55544次浏览 407人参与
# 对妈妈没说出口的话 #
19495次浏览 421人参与
# 作业帮求职进展汇总 #
50735次浏览 343人参与
# 异地恋该为对方跳槽吗 #
30534次浏览 150人参与