13 solutions
-
0
直接利用一个规则 i<j<k a[i]>a[k]>a[j]; 代码 #include #include <math.h> using namespace std; int a[1005]; int main() { int m;cin>>m; for(int i=1;i<=m;++i) { cin>>a[i]; }
for(int i=1;i<=m;++i) { for(int j=i+1;j<=m;++j) if(a[i]>a[j]) { for(int k=j+1;k<=m;k++) { if(a[i]>a[k]&&a[j]<a[k]) { cout<<"NO"; return 0; } } } } cout<<"YES"; return 0;
}
Information
- ID
- 291
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- 6
- Tags
- # Submissions
- 139
- Accepted
- 44
- Uploaded By