标签:i++ eps miss limits ons ber ini mos etc
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 6019 Accepted Submission(s): 1446
1 #include <iostream> 2 #include <string> 3 #include <cstdio> 4 #include <cstring> 5 #include <algorithm> 6 #include <climits> 7 #include <cmath> 8 #include <vector> 9 #include <queue> 10 #include <stack> 11 #include <set> 12 #include <map> 13 using namespace std; 14 typedef long long LL ; 15 typedef unsigned long long ULL ; 16 const int maxn = 1e5 + 10 ; 17 const int inf = 0x3f3f3f3f ; 18 const int npos = -1 ; 19 const int mod = 1e9 + 7 ; 20 const int mxx = 100 + 5 ; 21 const double eps = 1e-6 ; 22 const double PI = acos(-1.0) ; 23 24 int T, n, ans; 25 int a[maxn], c[maxn]; 26 int main(){ 27 // freopen("in.txt","r",stdin); 28 // freopen("out.txt","w",stdout); 29 while(~scanf("%d",&T)){ 30 while(T--){ 31 ans=1; 32 scanf("%d",&n); 33 scanf("%d",&a[1]); 34 c[0]=a[1]; 35 for(int i=2;i<=n;i++){ 36 scanf("%d",&a[i]); 37 if(a[i]>=c[ans-1]){ 38 c[ans++]=a[i]; 39 }else{ 40 c[upper_bound(c,c+ans,a[i])-c]=a[i]; 41 } 42 } 43 if(n-ans==1 || n==ans){ 44 puts("YES"); 45 }else{ 46 ans=1; 47 c[0]=a[n]; 48 for(int i=n-1;i>0;i--) 49 if(a[i]>=c[ans-1]){ 50 c[ans++]=a[i]; 51 }else{ 52 c[upper_bound(c,c+ans,a[i])-c]=a[i]; 53 } 54 if(n-ans==1 || n==ans) 55 puts("YES"); 56 else 57 puts("NO"); 58 } 59 } 60 } 61 return 0; 62 }
标签:i++ eps miss limits ons ber ini mos etc
原文地址:http://www.cnblogs.com/edward108/p/7636922.html