//弱鸡分享一下自己带吗 //第一题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; }
点赞 评论

相关推荐

03-13 16:51
北京大学 Java
躺平了的灰太狼很喜欢后撤步:北大✌️不薄纱
点赞 评论 收藏
分享
04-10 11:56
如皋中学 Java
高斯林的信徒:双c9能简历挂的?
点赞 评论 收藏
分享
牛客网
牛客企业服务