4 条题解
-
1莫言 (slz莫言) LV 10 @ 2024-12-10 12:33:21
#include <bits/stdc++.h> #define LL long long using namespace std; const int N = 1e3 + 10; const int INF = 0x3f3f3f3f; int num [N] , last , n , maxc = -INF; int main() { cin >> n; for(int i = 1; i <= n; i++) cin >> num[i]; last = num[1]; for(int i = 2; i <= n; i++) { if(num [i] > last) { if(num[i] < maxc) { cout << "NO"; return 0; } } else { last = num[i]; maxc = max(maxc,num[i]); } } cout<<"YES"; return 0; }
-
02024-7-29 10:02:07@
#include<bits/stdc++.h> using namespace std; int n; const int N=1e3+5; stack <int> s; int a[N]; int x=1,kk;
signed main() { cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; } s.push(1); for(int i=1;i<=n;i++) { s.push(i); kk=n+1; while (kk--){ if(s.top()==a[x]){ s.pop(); x++; } } } if(s.size()==1){ cout<<"YES"; } else{ cout<<"NO"; } return 0; }
-
02024-4-14 10:47:30@
#include <bits/stdc++.h> using namespace std; #define N 1005
int main() { int n, a[N], st[N] = {}; cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i = 1; i <= n; ++i) { for (int j = a[i] + 1; j <= n; ++j) { if (st[j] == 1) { cout << "NO"; return 0; } } for (int j = 1; j < a[i]; ++j) { if (st[j] == 0) st[j] = 1; } st[a[i]] = 2; } cout << "YES"; return 0; }
-
02024-4-14 10:47:19@
#include <bits/stdc++.h> using namespace std; #define N 1005
int main() { int n, a[N], st[N] = {}; cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i = 1; i <= n; ++i) { for (int j = a[i] + 1; j <= n; ++j) { if (st[j] == 1) { cout << "NO"; return 0; } } for (int j = 1; j < a[i]; ++j) { if (st[j] == 0) st[j] = 1; } st[a[i]] = 2; } cout << "YES"; return 0; }
- 1
信息
- ID
- 3047
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 6
- 标签
- 递交数
- 240
- 已通过
- 71
- 上传者