QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#575933 | #9313. Make Max | 2464447645 | WA | 24ms | 7676kb | C++14 | 1.8kb | 2024-09-19 17:27:33 | 2024-09-19 17:27:34 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
//#define int unsigned long long
#define int long long
#define yyy cout<<"YES\n"
#define nnn cout<<"NO\n"
#define endl '\n'
typedef pair<int, int> PII;
#define MAP map<int,int>
#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define fi first
#define se second
#define rrr return
int dx[4] = {0, 0, 1,-1};
int dy[4] = {1, -1, 0, 0};
//void print(__int128_t x){if (x < 0){putchar('-');x = -x;}
//if (x > 9) print(x / 10);putchar(x % 10 + '0');}
int qmod(int a,int b,int mod){int ans=1; a=a%mod;
while(b){if(b&1==1) ans=ans*a%mod;a=a*a%mod;b>>=1;}return ans;}
int qpow(int a,int b){int ans=1;while(b)
{if(b&1==1) ans=ans*a;a=a*a;b>>=1;}return ans;}
int getor(int l, int r){if (l == r) return l;
return l | ((1 << ( __lg(l ^ r) + 1)) - 1);}
int getand(int l, int r){if (l == r) return l;
return l & ((1ll << ( __lg(l ^ r) + 1)) - 1);}
inline int lowbit(int x){return x&(-x);}
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
int lcm(int a,int b){return a*b/gcd(a,b);}
const double pi=acos(-1);
const int N=2e6+10;
const int mod=1e9+7;
int a[N],b[N];
int pre[N],s[N];
void solve(){
int n;cin>>n;
for(int i=1;i<=n;i++) cin>>a[i];
stack<int> s1,s2;
int cnt1=0,cnt2=0,ans1=0,ans2=0;
for(int i=1;i<=n;i++){
int flag=0;
while(s1.size()&&s1.top()<a[i]) s1.pop(),cnt1++,flag=1;
if(s1.empty()||flag==1)ans1+=cnt1;
s1.push(a[i]);
}
//cout<<ans1<<endl;
reverse(a+1,a+1+n);
for(int i=1;i<=n;i++){
int flag=0;
while(s2.size()&&s2.top()<a[i]) s2.pop(),cnt2++,flag=1;
if(s2.empty()||flag==1)ans2+=cnt2;
s2.push(a[i]);
}
cout<<ans1+ans2<<endl;
}
signed main()
{
ios;
int t=1;
cin>>t;
while(t--){
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5724kb
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: 24ms
memory: 7676kb
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:
19621196182 18193529237
result:
wrong answer 1st numbers differ - expected: '4084978', found: '19621196182'