QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#574852 | #9313. Make Max | YuLan# | WA | 729ms | 35188kb | C++20 | 1.0kb | 2024-09-19 02:03:59 | 2024-09-19 02:03:59 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int main()
{
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
map<int,vector<int>> ma;
map<int,int> vis;
vector<int> qa;
for(int i=1;i<=n;i++)
{
int x;
cin>>x;
if(vis[x]==0)
{
qa.push_back(x);
ma[x].push_back(0);
vis[x]=1;
}
ma[x].push_back(i);
}
sort(qa.begin(),qa.end());
int m = qa.size();
int now = 0;
int ans = 0;
for(int i=m-1;i>=0;i--)
{
ma[qa[i]].push_back(n+1);
int len = ma[qa[i]].size();
for(int j=1;j<len;j++)
{
ans += ma[qa[i]][j] - ma[qa[i]][j-1] - 1;
}
ans -= now;
now += (len-2);
}
cout<<ans<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
input:
4 2 1 2 2 2 2 7 1 1 1 2 2 2 2 3 1 2 3
output:
1 0 3 3
result:
ok 4 number(s): "1 0 3 3"
Test #2:
score: -100
Wrong Answer
time: 729ms
memory: 35188kb
input:
2 198018 875421126 585870339 471894633 383529988 625397685 944061047 704695631 105113224 459022561 760848605 980735314 847376362 980571959 329939331 644635272 326439858 752879510 837384394 175179068 182094523 397239381 1199016 185143405 279638454 252374970 822030887 860312140 137248166 993229443 164...
output:
-1871121288 1010448805
result:
wrong answer 1st numbers differ - expected: '4084978', found: '-1871121288'