Submission #852323

# Submission time Handle Problem Language Result Execution time Memory
852323 2023-09-21T15:19:22 Z Mularstyle Pilot (NOI19_pilot) C++14
0 / 100
22 ms 15196 KB
#include<bits/stdc++.h>
using namespace std;

const int mxn =1000005;
int n,q,h[mxn],a[mxn],dp[mxn],L[mxn],R[mxn];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>q;
    for(int i=1;i<=n;i++)
        cin>>h[i];
    for(int i=1;i<=q;i++)
        cin>>a[i];
    stack<int> s;
    h[0]=h[n+1]=INT_MAX;
    s.push(0);
    for(int i=1;i<=n;i++)
    {
        while(h[s.top()]<h[i])
              s.pop();
        L[i]=s.top();
        s.push(i);
    }
    while(!s.empty())s.pop();
    s.push(n+1);
    for(int i=n;i>=1;i--)
    {
        while(h[s.top()]<=h[i])
            s.pop();
        L[i]=s.top();
        s.push(i);
    }
    for(int i=1;i<=n;i++)
        dp[h[i]]+=(i-L[i])*(R[i]-i);
    for(int i=1;i<=1000000;i++)
        dp[i]+=dp[i-1];
    for(int i=1;i<=q;i++)
        cout<<dp[a[i]]<<"\n";

}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 10584 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 10584 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 10584 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 10584 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 13144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 12856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 15196 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 10584 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 10584 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 10584 KB Output isn't correct
2 Halted 0 ms 0 KB -