QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#468674 | #8904. Рекорды и антирекорды | Kevin5307 | 0 | 8ms | 3816kb | C++23 | 1.5kb | 2024-07-08 22:38:14 | 2024-07-08 22:38:14 |
answer
//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
int n;
int a[200200];
int bit[200200];
int dp1[200200],dp2[200200];
void update(int p,int v)
{
while(p<200200)
{
bit[p]=max(bit[p],v);
p+=(p&(-p));
}
}
int query(int p)
{
int ans=0;
while(p)
{
ans=max(ans,bit[p]);
p-=(p&(-p));
}
return ans;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--)
{
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i];
memset(bit,0,sizeof(int)*(n+10));
for(int i=1;i<=n;i++)
{
dp1[i]=query(a[i])+1;
update(a[i],dp1[i]);
}
memset(bit,0,sizeof(int)*(n+10));
for(int i=1;i<=n;i++)
{
dp2[i]=query(n+1-a[i])+1;
update(n+1-a[i],dp2[i]);
}
int ans=*max_element(dp1+1,dp1+n+1)+*max_element(dp2+1,dp2+n+1);
cout<<ans-1<<'\n';
}
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3816kb
input:
120 5 3 1 4 2 5 5 3 4 2 5 1 5 5 4 2 1 3 5 1 2 5 4 3 5 2 4 3 1 5 5 3 1 5 2 4 5 1 4 2 3 5 5 5 1 4 3 2 5 1 5 3 2 4 5 3 1 2 5 4 5 3 1 5 4 2 5 1 2 3 4 5 5 1 5 2 4 3 5 3 5 2 1 4 5 2 1 5 4 3 5 1 5 3 4 2 5 3 1 4 5 2 5 2 1 4 5 3 5 1 3 5 4 2 5 5 3 4 2 1 5 2 1 3 5 4 5 2 3 1 5 4 5 2 4 3 5 1 5 4 3 2 5 1 5 4 5 2 ...
output:
4 5 5 5 5 4 5 5 5 4 4 5 5 4 4 5 4 4 5 5 4 4 5 5 4 5 4 5 4 5 5 5 5 5 5 5 4 5 5 5 5 5 5 5 4 4 5 5 4 5 5 4 4 5 4 5 4 4 5 5 5 5 5 5 4 5 4 5 5 5 5 4 4 4 4 5 5 5 4 5 4 4 5 4 5 4 5 5 4 4 4 4 5 5 4 4 5 5 5 4 5 4 5 5 4 4 5 4 5 5 4 4 5 5 5 4 5 4 4 4
result:
wrong answer 1st numbers differ - expected: '5', found: '4'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Wrong Answer
Test #49:
score: 0
Wrong Answer
time: 8ms
memory: 3692kb
input:
9000 8 4 1 2 3 5 6 7 8 12 1 2 12 3 4 5 6 7 8 9 10 11 15 4 1 13 2 15 3 5 6 7 8 9 10 11 12 14 15 4 5 10 14 1 2 3 6 7 8 9 11 12 13 15 9 4 1 2 3 5 6 7 8 9 13 1 4 9 12 2 3 5 6 7 8 10 11 13 14 1 10 2 3 4 5 6 7 8 9 11 12 13 14 15 1 6 7 2 3 4 5 8 9 10 11 12 13 14 15 12 1 4 6 10 12 2 3 5 7 8 9 11 8 7 8 1 2 3...
output:
8 12 13 12 9 11 14 14 9 7 12 15 6 13 8 9 8 11 10 5 7 9 10 12 8 6 14 6 6 10 6 9 8 13 5 14 13 5 6 5 9 12 6 12 14 8 4 12 12 8 9 9 11 9 13 6 6 5 11 11 10 6 4 14 12 14 12 6 14 8 8 9 7 9 15 10 7 13 8 11 5 6 8 12 9 8 12 8 9 10 8 6 9 11 10 15 12 11 12 7 7 7 9 7 12 6 12 5 6 9 10 7 12 6 7 8 12 12 10 5 8 10 7 ...
result:
wrong answer 23rd numbers differ - expected: '11', found: '10'
Subtask #6:
score: 0
Skipped
Dependency #1:
0%