QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#570728 | #9313. Make Max | luoxxx | WA | 28ms | 5096kb | C++20 | 1.0kb | 2024-09-17 17:24:05 | 2024-09-17 17:24:06 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define int long long
#define pb push_back
using pii =pair<int,int>;
#define INF 0x3f3f3f3f
const int N=1e5+5;
const int mod=998244353;
ll ksm(ll a,ll b){ll ans=1;while(b){if(b&1){ans*=a;ans=ans%mod;}a=a*a;a%=mod;b>>=1;}return ans;}
ll gcd(ll a,ll b){ll t=a%b;while(t){a=b;b=t;t=a%b;}return b;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll get_inv(ll x){return ksm(x,mod-2);}
int n; int cnt=0;
int insert(stack<int>&a,int x)
{
int f=0;
while (!a.empty() && a.top() < x) {
a.pop();cnt++;f=1;
}
if(!f) cnt=0;
a.push(x);
return cnt;
}
void solve()
{
stack<int>a;cnt=0;
cin>>n;vector<int>c(n+1);int sum=0;
for(int i=1;i<=n;i++)
{
cin>>c[i];
}
sum+=insert(a,c[1]);
for(int i=2;i<=n;i++)
{
sum+=insert(a,c[i]);
}
cout<<sum<<endl;
}
signed main()
{
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int _;cin>>_;while(_--)
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3768kb
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: 28ms
memory: 5096kb
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:
260879 250841
result:
wrong answer 1st numbers differ - expected: '4084978', found: '260879'