Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
同一段代码,前些天TLE,今天一交就AC了,也不知道是怎么回事,发现一个书写错误#include <stdio.h> #include<stdlib.h>e ~~ #include<algorithm> using namespace std; int comp(const void* a,const void *b) { return *(unsigned int*)a-*(unsigned int*)b; } unsigned int a[1000010]; int main() {int i; int n,flag1,flag2; while(scanf("%d",&n)!=EOF) { for(i=0;i<n;i++) { scanf("%d",&a[i]); } sort(a,a+n); // qsort(a,n,sizeof(unsigned int),comp); flag1=0,flag2=0; if(a[0]+a[1]<=a[n-1]) { flag1=1; } for(i=2;i<n;i++) { if(a[i-1]+a[i-2]>a[i]) { flag2=1; break; } } if(flag1==1&&flag2==1) { printf("The set is accepted.\n"); } else { printf("The set is rejected.\n"); } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator