QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#780876 | #9787. Shrek's Song of the Swamp | GenshinImpactShutdown# | WA | 1ms | 5908kb | C++14 | 666b | 2024-11-25 13:47:34 | 2024-11-25 13:47:34 |
Judging History
answer
#include<bits/stdc++.h>
#define All(x) x.begin(),x.end()
using namespace std;
using ull=unsigned long long;
using ll=long long;
using bint=__int128;
using ld=long double;
using pii=pair<int,int>;
using vi=vector<int>;
const int N=1e6+5;
int n,a[N],f[N],g[N],ls[N];
unordered_map<int,int> tg;
int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=n;i++)
{
ls[i]=tg[a[i]];
tg[a[i]]=i;
}for(int i=1;i<=n;i++)
{
f[i]=f[ls[i]]+1;
if(ls[i])f[i]=max(f[i],g[ls[i]-1]+2);
g[i]=max(g[i-1],f[i]);
}cout<<g[n]<<'\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5908kb
input:
9 1 2 3 1 3 1 2 3 2
output:
5
result:
ok 1 number(s): "5"
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 5680kb
input:
6 3 4 10 1 -3 5
output:
1
result:
wrong answer 1st numbers differ - expected: '0', found: '1'