QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#774653 | #9787. Shrek's Song of the Swamp | ucup-team5697# | WA | 25ms | 6288kb | C++23 | 996b | 2024-11-23 13:37:29 | 2024-11-23 13:37:32 |
Judging History
answer
#pragma GCC optimize(2)
#pragma GCC optimize("Ofast")
#include<map>
#include<set>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<cstdio>
#include<vector>
#include<string>
#include<bitset>
#include<numeric>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN=2e5+10;
const int N=2e5;
const int INF=0x3f3f3f3f;
const long long LINF=0x3f3f3f3f3f3f3f3f;
int n;
int a[MAXN],dp[MAXN],pre[MAXN];
map <int,int> buc;
inline void solve(){
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
int x;
scanf("%d",&x);
pre[i]=pre[i-1];
int p=buc[x];
buc[x]=i;
if(!p){
continue;
}
dp[i]=max(pre[p-1]+2,dp[p]+1);
pre[i]=max(pre[i],dp[i]);
}
printf("%d\n",pre[n]);
}
signed main(){
#ifdef LOCAL
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
atexit([](){fprintf(stderr,"%.3lfs\n",(double)clock()/CLOCKS_PER_SEC);});
#endif
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3900kb
input:
9 1 2 3 1 3 1 2 3 2
output:
5
result:
ok 1 number(s): "5"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3936kb
input:
6 3 4 10 1 -3 5
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
4 1 2 1 1
output:
3
result:
ok 1 number(s): "3"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
9 1 2 3 1 3 1 2 3 2
output:
5
result:
ok 1 number(s): "5"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
6 3 4 10 1 -3 5
output:
0
result:
ok 1 number(s): "0"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3908kb
input:
4 1 2 1 1
output:
3
result:
ok 1 number(s): "3"
Test #7:
score: -100
Wrong Answer
time: 25ms
memory: 6288kb
input:
1000000 7 2 6 10 3 1 9 3 5 3 8 10 8 4 10 1 9 5 2 7 9 7 10 4 5 2 10 9 6 3 6 10 5 2 9 3 4 6 6 10 10 6 1 9 4 5 7 2 2 10 2 8 5 6 1 8 3 9 1 8 1 6 6 1 4 9 3 8 1 4 10 10 7 4 9 8 7 1 9 1 5 5 6 5 5 6 7 4 10 6 1 6 10 6 7 8 1 9 1 9 10 3 2 5 2 3 9 2 9 4 8 4 8 9 2 6 8 4 5 3 3 3 2 6 8 10 2 10 2 4 10 10 10 7 1 3 2...
output:
86354
result:
wrong answer 1st numbers differ - expected: '463867', found: '86354'