QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#623580 | #2225. Terrace Hill | C1942huangjiaxu | WA | 0ms | 3768kb | C++14 | 335b | 2024-10-09 13:15:59 | 2024-10-09 13:16:01 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+5;
typedef long long ll;
int n,a[N],st[N],tp;
ll ans;
int main(){
scanf("%d",&n);
for(int i=1;i<=n;++i){
scanf("%d",&a[i]);
while(tp&&a[st[tp]]<a[i])--tp;
if(tp&&a[st[tp]]==a[i])ans+=i-1-st[tp];
st[++tp]=a[i];
}
printf("%lld\n",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3768kb
input:
103 198 105 115 81 255 74 236 41 205 186 171 242 251 227 70 124 194 84 248 27 232 231 141 118 90 46 99 51 159 201 154 102 50 13 183 49 88 163 90 37 93 5 23 88 233 94 212 171 178 205 198 155 180 84 17 14 130 116 65 33 61 220 135 112 233 62 161 65 225 252 103 62 1 126 151 234 220 107 150 143 56 92 42 ...
output:
7
result:
wrong answer 1st lines differ - expected: '19', found: '7'