#include <bits/stdc++.h>
using namespace std;
#define sz(s) (int)s.size()
#define ff first
#define ss second
#define ll long long
const int N = 1e5;
int n, m, a[N], b[N], ans;
vector <int> v2, v3;
void f(int x){
if(x == n+1){
long long s = 0;
vector <int> v, v1;
for(int i = 1; i <= n; i++){
s += a[i];
if(b[i] == 1){
v.push_back(s);
s = 0;
}
}
v1 = v;
sort(v.begin(), v.end());
if(v == v1 and ans < sz(v)){
ans = max(ans,sz(v));
v2.clear();
v3.clear();
v3 = v;
for(int i = 1; i <= n; i++){
v2.push_back(b[i]);
}
}
return;
}
for(int i = 0; i < 2; i++){
b[x] = i;
f(x+1);
}
}
int main(){
ios::sync_with_stdio (false); cin.tie(nullptr);
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i];
}
f(1);
cout << ans;
// for(auto i : v2){
// cout << i << ' ';
// }
// cout << '\n';
// for(auto i : v3){
// cout << i << ' ';
// }
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
468 KB |
Output is correct |
4 |
Correct |
216 ms |
348 KB |
Output is correct |
5 |
Correct |
207 ms |
344 KB |
Output is correct |
6 |
Correct |
203 ms |
344 KB |
Output is correct |
7 |
Correct |
7 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
191 ms |
348 KB |
Output is correct |
10 |
Correct |
196 ms |
348 KB |
Output is correct |
11 |
Correct |
183 ms |
348 KB |
Output is correct |
12 |
Correct |
191 ms |
344 KB |
Output is correct |
13 |
Correct |
183 ms |
348 KB |
Output is correct |
14 |
Correct |
202 ms |
348 KB |
Output is correct |
15 |
Correct |
194 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
468 KB |
Output is correct |
4 |
Correct |
216 ms |
348 KB |
Output is correct |
5 |
Correct |
207 ms |
344 KB |
Output is correct |
6 |
Correct |
203 ms |
344 KB |
Output is correct |
7 |
Correct |
7 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
191 ms |
348 KB |
Output is correct |
10 |
Correct |
196 ms |
348 KB |
Output is correct |
11 |
Correct |
183 ms |
348 KB |
Output is correct |
12 |
Correct |
191 ms |
344 KB |
Output is correct |
13 |
Correct |
183 ms |
348 KB |
Output is correct |
14 |
Correct |
202 ms |
348 KB |
Output is correct |
15 |
Correct |
194 ms |
344 KB |
Output is correct |
16 |
Execution timed out |
1575 ms |
348 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
468 KB |
Output is correct |
4 |
Correct |
216 ms |
348 KB |
Output is correct |
5 |
Correct |
207 ms |
344 KB |
Output is correct |
6 |
Correct |
203 ms |
344 KB |
Output is correct |
7 |
Correct |
7 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
191 ms |
348 KB |
Output is correct |
10 |
Correct |
196 ms |
348 KB |
Output is correct |
11 |
Correct |
183 ms |
348 KB |
Output is correct |
12 |
Correct |
191 ms |
344 KB |
Output is correct |
13 |
Correct |
183 ms |
348 KB |
Output is correct |
14 |
Correct |
202 ms |
348 KB |
Output is correct |
15 |
Correct |
194 ms |
344 KB |
Output is correct |
16 |
Execution timed out |
1575 ms |
348 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
468 KB |
Output is correct |
4 |
Correct |
216 ms |
348 KB |
Output is correct |
5 |
Correct |
207 ms |
344 KB |
Output is correct |
6 |
Correct |
203 ms |
344 KB |
Output is correct |
7 |
Correct |
7 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
191 ms |
348 KB |
Output is correct |
10 |
Correct |
196 ms |
348 KB |
Output is correct |
11 |
Correct |
183 ms |
348 KB |
Output is correct |
12 |
Correct |
191 ms |
344 KB |
Output is correct |
13 |
Correct |
183 ms |
348 KB |
Output is correct |
14 |
Correct |
202 ms |
348 KB |
Output is correct |
15 |
Correct |
194 ms |
344 KB |
Output is correct |
16 |
Execution timed out |
1575 ms |
348 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
468 KB |
Output is correct |
4 |
Correct |
216 ms |
348 KB |
Output is correct |
5 |
Correct |
207 ms |
344 KB |
Output is correct |
6 |
Correct |
203 ms |
344 KB |
Output is correct |
7 |
Correct |
7 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
191 ms |
348 KB |
Output is correct |
10 |
Correct |
196 ms |
348 KB |
Output is correct |
11 |
Correct |
183 ms |
348 KB |
Output is correct |
12 |
Correct |
191 ms |
344 KB |
Output is correct |
13 |
Correct |
183 ms |
348 KB |
Output is correct |
14 |
Correct |
202 ms |
348 KB |
Output is correct |
15 |
Correct |
194 ms |
344 KB |
Output is correct |
16 |
Execution timed out |
1575 ms |
348 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |