Submission #1347377

#TimeUsernameProblemLanguageResultExecution timeMemory
1347377wynDucks And Buttons (NOI25_duckbuttons)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

vector<int64_t> A;
int64_t N, D;

int main(){
    cin >> N >> D;
    A.assign( N , 0 );
    for ( auto &a : A )
        cin >> a;

    deque< tuple<int64_t,int64_t> > buf ;
    buf.push_back( {1e18,0} );

    for ( int64_t n=0 ; n<N ; n++ ){
        auto a = A[n];

        while( auto [h,n] = buf.back() ){
            if( a >= h ){
                buf.pop_back();
            }
            else {
                break;
            }
        }

        buf.push_back( {a, n} );
    }

    int64_t ans = 0;
    for( int64_t i=1 ; i<buf.size() ; i++ ){
        auto [h,n] = buf[i];
        auto [h1,n1] = buf[i-1];

        ans += h*(n-n1);
    }
    cout << ans << endl;
    return 0;
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:19:21: error: expected unqualified-id before '[' token
   19 |         while( auto [h,n] = buf.back() ){
      |                     ^
Main.cpp:20:22: error: 'h' was not declared in this scope
   20 |             if( a >= h ){
      |                      ^