QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#891504#664. Triangleship2077WA 0ms3712kbC++231013b2025-02-09 14:46:072025-02-09 14:46:08

Judging History

This is the latest submission verdict.

  • [2025-02-09 14:46:08]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3712kb
  • [2025-02-09 14:46:07]
  • Submitted

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int M=1e5+5;
int n,ans,sum,cnt,a[M];
int read(){
	int x=0;char ch=getchar();
	while (!isdigit(ch)) ch=getchar();
	while (isdigit(ch)) x=x*10+ch-48,ch=getchar();
	return x;
}
bool chk(int a,int b,int c,int d,int e,int f){return a<b+c&&d<e+f;}
bool check(int a,int b,int c,int d,int e,int f){
	return chk(a,b,c,d,e,f)&&chk(a,b,d,c,e,f)&&chk(a,b,e,c,d,f)&&chk(a,b,f,c,d,e)&&
		   chk(a,c,d,b,e,f)&&chk(a,c,e,b,d,f)&&chk(a,c,f,b,d,e)&&
		   chk(a,d,e,b,c,f)&&chk(a,d,f,b,c,e)&&
		   chk(a,e,f,b,c,d);
}
signed main(){ n=read();
	for (int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1,greater<int>());n=min(n,300ll);
	for (int i=3;i<=n;i++) 
		if (a[i-2]>a[i-1]+a[i]){
			sum+=a[i-2]+a[i-1]+a[i];i+=2;
			if (++cnt==2) {ans=sum;break;}
		}
	for (int i=1;i+5<=n;i++)
		if (check(a[i],a[i+1],a[i+2],a[i+3],a[i+4],a[i+5]))
			ans=max(ans,a[i]+a[i+1]+a[i+2]+a[i+3]+a[i+4]+a[i+5]);
	printf("%lld\n",ans);
	return 0;
}	

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3712kb

input:

100
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

output:

6

result:

ok single line: '6'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

100
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1

output:

6

result:

ok single line: '6'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3712kb

input:

100
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

output:

6

result:

wrong answer 1st lines differ - expected: '8', found: '6'