# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
963952 | 2024-04-16T05:23:08 Z | Aiperiii | Money (IZhO17_money) | C++14 | 221 ms | 262144 KB |
#include <bits/stdc++.h> #define int long long #define ff first #define ss second #define pb push_back #define all(x) x.begin(),x.end() using namespace std; const int N=1e3+5; int cnt[N][N]; signed main(){ ios_base::sync_with_stdio(); cin.tie(0);cout.tie(0); int n; cin>>n; vector <int> a(n+1); vector <int> sr; for(int i=1;i<=n;i++){ cin>>a[i]; } vector <int> v; vector <vector <int> > vec; vec.pb({}); for(int i=1;i<=n;i++){ v.pb(a[i]); vec.pb(v); } for(int i=0;i<vec.size();i++){ sort(all(vec[i])); } for(int i=0;i<=n;i++){ for(int j=0;j<=n;j++){ cnt[i][j]=1e9; } } cnt[0][0]=0; for(int i=1;i<=n;i++){ for(int j=i;j<=n;j++){ int mn=1e9,ind=-1; for(int k=j;k>=i;k--){ bool ok=0; auto it=upper_bound(all(vec[k-1]),a[k]); if(it==vec[k-1].end() or *it>=a[j])ok=1; if(ok){ cnt[i][j]=min(cnt[i][j],cnt[i-1][k-1]+1); } if(k-1>=i && a[k]<a[k-1])break; } } } for(int i=1;i<=n;i++){ if(cnt[i][n]!=1e9){ cout<<i<<"\n";return 0; } } } /* 6 3 6 4 5 1 2 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 448 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 448 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 444 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 448 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 448 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 444 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 504 KB | Output is correct |
20 | Correct | 1 ms | 344 KB | Output is correct |
21 | Correct | 0 ms | 352 KB | Output is correct |
22 | Correct | 0 ms | 444 KB | Output is correct |
23 | Correct | 0 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 344 KB | Output is correct |
25 | Correct | 1 ms | 344 KB | Output is correct |
26 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 448 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 448 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 444 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 504 KB | Output is correct |
20 | Correct | 1 ms | 344 KB | Output is correct |
21 | Correct | 0 ms | 352 KB | Output is correct |
22 | Correct | 0 ms | 444 KB | Output is correct |
23 | Correct | 0 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 344 KB | Output is correct |
25 | Correct | 1 ms | 344 KB | Output is correct |
26 | Correct | 1 ms | 348 KB | Output is correct |
27 | Correct | 2 ms | 2656 KB | Output is correct |
28 | Correct | 1 ms | 2392 KB | Output is correct |
29 | Correct | 1 ms | 2396 KB | Output is correct |
30 | Correct | 1 ms | 2396 KB | Output is correct |
31 | Correct | 1 ms | 2460 KB | Output is correct |
32 | Correct | 3 ms | 4956 KB | Output is correct |
33 | Correct | 3 ms | 4956 KB | Output is correct |
34 | Correct | 3 ms | 4956 KB | Output is correct |
35 | Correct | 3 ms | 4952 KB | Output is correct |
36 | Correct | 5 ms | 4956 KB | Output is correct |
37 | Correct | 3 ms | 4956 KB | Output is correct |
38 | Correct | 3 ms | 4952 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 448 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 448 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 444 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 504 KB | Output is correct |
20 | Correct | 1 ms | 344 KB | Output is correct |
21 | Correct | 0 ms | 352 KB | Output is correct |
22 | Correct | 0 ms | 444 KB | Output is correct |
23 | Correct | 0 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 344 KB | Output is correct |
25 | Correct | 1 ms | 344 KB | Output is correct |
26 | Correct | 1 ms | 348 KB | Output is correct |
27 | Correct | 2 ms | 2656 KB | Output is correct |
28 | Correct | 1 ms | 2392 KB | Output is correct |
29 | Correct | 1 ms | 2396 KB | Output is correct |
30 | Correct | 1 ms | 2396 KB | Output is correct |
31 | Correct | 1 ms | 2460 KB | Output is correct |
32 | Correct | 3 ms | 4956 KB | Output is correct |
33 | Correct | 3 ms | 4956 KB | Output is correct |
34 | Correct | 3 ms | 4956 KB | Output is correct |
35 | Correct | 3 ms | 4952 KB | Output is correct |
36 | Correct | 5 ms | 4956 KB | Output is correct |
37 | Correct | 3 ms | 4956 KB | Output is correct |
38 | Correct | 3 ms | 4952 KB | Output is correct |
39 | Runtime error | 221 ms | 262144 KB | Execution killed with signal 9 |
40 | Halted | 0 ms | 0 KB | - |