QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#570639 | #9313. Make Max | zeroeeeooo# | WA | 0ms | 3808kb | C++20 | 1.2kb | 2024-09-17 16:51:09 | 2024-09-17 16:51:09 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '/n'
void solve(){
int n;
cin>>n;
vector<int>a={0};
int ans = 0;
for(int i = 1;i<=n;i++){
int num;cin>>num;
a.push_back(num);
}
stack<int>num;
num.push(1);
vector<int>change;
for(int i = 2;i<=n;i++){
while(num.size()&&a[i]>a[num.top()]){
change.push_back(num.top());
num.pop();
ans++;
}
num.push(i);
int cnt = 0;
int last = -1;
if(change.size())last = change[0];
for(int i = 0;i<change.size();i++){
if(last != a[change[i]])ans+=cnt;
last = a[change[i]];
cnt++;
a[change[i]]=a[num.top()];
num.push(change[i]);
}
change.clear();
}
int last = a[num.top()],cnt = 0;
while(num.size()){
if(last!=a[num.top()]){
last = a[num.top()];
ans+=cnt;
}
num.pop();
cnt++;
}
cout<<ans<<endl;
}
signed main(){
ios::sync_with_stdio(false);
int t;
cin>>t;
while(t--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3808kb
input:
4 2 1 2 2 2 2 7 1 1 1 2 2 2 2 3 1 2 3
output:
112142012142312142312142
result:
wrong output format Expected integer, but "112142012142312142312142" found