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

相关推荐

07-18 15:02
门头沟学院 Java
刚打开网申页面就不想填了,还是不要为难自己了
poppinzhan...:多益老行业毒瘤了,碰到徐波这种恶心的烂人,去了也是受罪。
点赞 评论 收藏
分享
06-07 19:59
门头沟学院 C++
补药卡我啊😭:都快15年前的了还在11新特性
你的简历改到第几版了
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务