Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
52996 Ender 木薯与身高 C++ 通过 100 311 MS 264 KB 466 2022-07-20 13:17:37

Tests(20/20):


#include <iostream> #include <vector> #include <algorithm> #define ll long long using namespace std; int a[1000010],b[1000010]; int main() { int n,top = 0; ll ans = 0; cin>>n; for(int i(1);i <= n;i++) { int x; cin>>x; if(x > a[top]) { a[++top] = x; b[top] = i; } else { int pos = upper_bound(a + 1,a + top + 1,x) - a; if(pos > top) continue; ans+=i - b[pos]; } } cout<<ans; return 0; }


测评信息: