CodeForces 733D - Kostya the Sculptor
来源:互联网 发布:辐射4派普优化 编辑:程序博客网 时间:2024/06/06 04:04
题目大意: 给定
问你最后想要的长方体有最大的内接圆,问你如何选择?
思路: 长方体的内接圆取决于它的最短边。
所以,每次必然是两个长方体的长边和次长边组成的面进行合并,然后组成的新的长方体的最短边就是这个长方体能得到的最大直径。
用一个
最后每次插入只要查询有没有对应的长方体,然后用一个
根据最大值来输出结果。
#include <cstdio>#include <string>#include<iostream>#include<vector>#include <stack>#include <queue>#include <map>#include <cstdlib>#include<string.h>#include <cstring>#include <algorithm>using namespace std;typedef long long ll;typedef pair<int, int>pii;typedef pair<ll, ll> pll;typedef pair<int, ll> pil;int main(){ int n; scanf("%d", &n); map<pll, pll>ma; ll nomaxx = -1; int pos = -1; ll tmaxx = -1; int p1 = -1, p2 = -1; for (int i = 0; i < n; i++) { ll a[3]; for (int j = 0; j < 3; j++)scanf("%I64d", &a[j]); sort(a, a + 3); if (nomaxx < a[0]) { nomaxx = a[0]; pos = i + 1; } pll tmp = pll(a[2], a[1]); ll b[3]; b[0] = a[2], b[1] = a[1], b[0] = ma[tmp].first + a[0]; sort(b, b + 3); if (ma[tmp].first!=0&&tmaxx < b[0]) { tmaxx = b[0]; p1 = ma[tmp].second; p2 = i + 1; } if (ma[tmp].first < a[0]) { ma[tmp].second = i + 1; ma[tmp].first = a[0]; } } if (nomaxx>tmaxx) { printf("1\n%d\n", pos); } else { printf("2\n%d %d\n", p1,p2); } //system("pause");}
0 0
- 【25.47%】【codeforces 733D】Kostya the Sculptor
- 【Codeforces 733D】 Kostya the Sculptor【贪心】
- Codeforces 733D Kostya the Sculptor 贪心
- codeforces 733D Kostya the Sculptor
- Codeforces 733D Kostya the Sculptor
- CodeForces 733D Kostya the Sculptor
- codeforces 733D. Kostya the Sculptor
- CodeForces 733D - Kostya the Sculptor
- Codeforces 733D Kostya the Sculptor
- 733D Kostya the Sculptor
- Codeforces 733D D. Kostya the Sculptor By Assassin
- 733D Kostya the Sculptor codeforces (贪心)
- CodeForces 733D Kostya the Sculptor 思维题
- CodeForces - 733D Kostya the Sculptor (STL SET)
- CodeForces 733 D.Kostya the Sculptor(水~)
- Kostya the Sculptor CodeForces
- Codeforces Round #378 (Div. 2) D. Kostya the Sculptor【贪心】
- Codeforces Round #378 (Div. 2)-D. Kostya the Sculptor(multiset)
- tornado初印象
- Linux 下MySQL 访问示例
- 十二周进制转换
- placeholder
- C#中StructLayout的特性
- CodeForces 733D - Kostya the Sculptor
- android Service实现后台下载
- android:process="system"的误用 (2014-03-27 17:33:15)
- spring @Transactional注解参数详解
- 初识google多语言通信框架gRPC系列(一)概述
- c++小知识点3.0
- Vue.js——vue-resource全攻略
- struts2 如何动态限制控制文件图片上传大小?
- android上传图片至服务器