codeforces 733D
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了codeforces 733D相关的知识,希望对你有一定的参考价值。
明白了自己这么菜的原因多半是赛后不肯去补那些需要多花点时间思考的题目以及效率不高,但愿现在还不算晚。。。
#include<bits/stdc++.h> #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<string.h> #define maxint 999999999 #define MAXN 999999 typedef long long ll; using namespace std; bool vis[MAXN]; int n,m,k; int num1[MAXN]; char str[MAXN]; struct node{ ll a,b,c,num; }sqr[MAXN]; bool cmp(node x,node y) { if(x.a==y.a) return x.b>y.b; else return x.a>y.a; } int main() { ll a,b,c; ll f1,f2,f3; while(scanf("%d",&n)!=EOF) { ll MAX=0; for(int i=1;i<=n;i++) { scanf("%lld%lld%lld",&a,&b,&c); ll sum=a+b+c; sqr[i].a=max(a,max(b,c)); sqr[i].c=min(a,min(b,c)); sqr[i].b=(sum-sqr[i].a-sqr[i].c); sqr[i].num=i; if(MAX < sqr[i].c) { f1=i; MAX=sqr[i].c; } } sort(sqr+1,sqr+1+n,cmp); int flag=0; for(int i=1;i<n;i++) { if(sqr[i].a==sqr[i+1].a&&sqr[i].b==sqr[i+1].b) { if(MAX<min((sqr[i].c+sqr[i+1].c),sqr[i].b)) { MAX=min((sqr[i].c+sqr[i+1].c),sqr[i].b); flag=1; f2=sqr[i].num; f3=sqr[i+1].num; } } } if(!flag) { printf("1\n"); printf("%lld\n",f1); } else { printf("2\n"); printf("%lld %lld\n",f2,f3); } }return 0; }
以上是关于codeforces 733D的主要内容,如果未能解决你的问题,请参考以下文章
CodeForces 733D Kostya the Sculptor
CF733D Kostya the Sculptor[贪心 排序]
[Codeforces Round #522 (Div. 2, based on Technocup 2019 Elimination Round 3)][C. Playing Piano](代码片段