Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
141746 | 刘嘉乐 | 音乐会 | C++ | 解答错误 | 30 | 85 MS | 2168 KB | 331 | 2024-04-06 10:42:14 |
#include<bits/stdc++.h> using namespace std; int a[500005],tot; int ai[250]; int main(){ int n; cin>>n; int sum = 0; for(int i=1;i<=n;i++){ int x; cin>>x; ai[x]++; while(tot>0&&a[tot]<x){ sum++; ai[a[tot]]--; tot--; } sum+=ai[a[tot]]; a[++tot] = x; } cout<<sum<<'\n'; return 0; }