#include "bits/stdc++.h"
#include "towers.h"
//#define int long long
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;
vector<int> xd;
vector<int> bak;
vector<array<int,2>> v;
void init(int n, vector<int> ar) {
if(n<=2) return;
vector<array<int,2>> v2;
bak=ar;
if(ar[0]>ar[1]) v2.push_back({ar[0],0});
else {xd.push_back(0);v2.push_back({ar[0],1});}
for(int i=1;i<n-1;i++){
if(ar[i]>ar[i-1] && ar[i]>ar[i+1]) v2.push_back({ar[i],0});
else if(ar[i]<ar[i-1] && ar[i]<ar[i+1]) {xd.push_back(i);v2.push_back({ar[i],1});}
}
if(ar[n-1]<ar[n-2]) {xd.push_back(n-1);v2.push_back({ar[n-1],1});}
else v2.push_back({ar[n-1],0});
}
int max_towers(int l, int r, int d){
if(d==1){
if(r-l<=1) return 1;
int it=upper_bound(all(xd),r-1)-xd.begin();
int it2=lower_bound(all(xd),l+1)-xd.begin();
int cur=it-it2;
if(bak[l]<bak[l+1]) cur++;
if(bak[r]<bak[r-1]) cur++;
return max(1,cur);
}
if(bak[l]>bak[l+1]) v.push_back({bak[l],0});
else v.push_back({bak[l],1});
for(int i=l+1;i<r-1;i++){
if(bak[i]>bak[i-1] && bak[i]>bak[i+1]) v.push_back({bak[i],0});
else if(bak[i]<bak[i-1] && bak[i]<bak[i+1]) v.push_back({bak[i],1});
}
if(bak[r]<bak[r-1]) v.push_back({bak[r],1});
else v.push_back({bak[r],0});
int dp[sz(v)+5];
int maxi=1;
for(int i=0;i<sz(v);i++){
dp[i]=1;
int lol=0;
for(int j=i-1;j>=0;j--){
if(v[j][1]==0) lol=max(lol,v[j][0]);
else if(lol>v[j][0]) dp[i]=max(dp[i],dp[j]+1);
}
maxi=max(maxi,dp[i]);
}
return maxi;
}
/*void _(){
int n,q;cin >> n >> q;
int ar[n+5];
for(int i=1;i<=n;i++) cin >> ar[i];
if(n<=2) return;
vector<array<int,2>> v;
vector<int> xd;
if(ar[1]>ar[2]) v.push_back({ar[1],0});
else {xd.push_back(1);v.push_back({ar[1],1});}
for(int i=2;i<n;i++){
if(ar[i]>ar[i-1] && ar[i]>ar[i+1]) v.push_back({ar[i],0});
else if(ar[i]<ar[i-1] && ar[i]<ar[i+1]) {xd.push_back(i);v.push_back({ar[i],1});}
}
if(ar[n]<ar[n-1]) {xd.push_back(n);v.push_back({ar[n],1});}
else v.push_back({ar[n],0});
while(q--){
int l,r,d;
cin >> l >> r >> d;
int it=upper_bound(all(xd),r)-xd.begin();
int it2=lower_bound(all(xd),l)-xd.begin();
cout << it-it2 << '\n';
}
}
int32_t main(){
cin.tie(0); ios::sync_with_stdio(0);
int tc=1;//cin >> tc;
while(tc--) _();
return 0;
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4037 ms |
1164 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
596 KB |
1st lines differ - on the 1st token, expected: '13', found: '16' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
596 KB |
1st lines differ - on the 1st token, expected: '13', found: '16' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
361 ms |
2768 KB |
Output is correct |
2 |
Correct |
497 ms |
3024 KB |
Output is correct |
3 |
Correct |
538 ms |
2748 KB |
Output is correct |
4 |
Correct |
568 ms |
3024 KB |
Output is correct |
5 |
Correct |
502 ms |
3024 KB |
Output is correct |
6 |
Correct |
548 ms |
3024 KB |
Output is correct |
7 |
Correct |
537 ms |
3024 KB |
Output is correct |
8 |
Correct |
553 ms |
1368 KB |
Output is correct |
9 |
Correct |
493 ms |
1368 KB |
Output is correct |
10 |
Correct |
443 ms |
1452 KB |
Output is correct |
11 |
Correct |
386 ms |
1604 KB |
Output is correct |
12 |
Correct |
462 ms |
1572 KB |
Output is correct |
13 |
Correct |
442 ms |
1604 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
12 ms |
2848 KB |
Output is correct |
18 |
Correct |
9 ms |
3020 KB |
Output is correct |
19 |
Correct |
8 ms |
3024 KB |
Output is correct |
20 |
Correct |
14 ms |
1596 KB |
Output is correct |
21 |
Correct |
9 ms |
1368 KB |
Output is correct |
22 |
Correct |
8 ms |
2852 KB |
Output is correct |
23 |
Correct |
8 ms |
3024 KB |
Output is correct |
24 |
Correct |
15 ms |
2900 KB |
Output is correct |
25 |
Correct |
7 ms |
1368 KB |
Output is correct |
26 |
Correct |
8 ms |
1368 KB |
Output is correct |
27 |
Correct |
0 ms |
344 KB |
Output is correct |
28 |
Correct |
1 ms |
388 KB |
Output is correct |
29 |
Correct |
1 ms |
344 KB |
Output is correct |
30 |
Correct |
1 ms |
344 KB |
Output is correct |
31 |
Correct |
0 ms |
344 KB |
Output is correct |
32 |
Correct |
0 ms |
344 KB |
Output is correct |
33 |
Correct |
0 ms |
344 KB |
Output is correct |
34 |
Correct |
1 ms |
344 KB |
Output is correct |
35 |
Correct |
0 ms |
344 KB |
Output is correct |
36 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4054 ms |
1920 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
596 KB |
1st lines differ - on the 1st token, expected: '13', found: '16' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4037 ms |
1164 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |