QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#120491#3549. 262144 Revisitedpandapythoner#Compile Error//C++141.6kb2023-07-06 19:24:422024-05-31 14:22:06

Judging History

你现在查看的是最新测评结果

  • [2024-05-31 14:22:06]
  • 评测
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-06 19:24:42]
  • 提交

answer

#ifndef LOCAL
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#endif

#include <bits/stdc++.h>


using namespace std;


#define ll long long
#define flt double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#ifdef LOCAL
bool local = true;
#else
bool local = false;
#endif


int n;
vector<int> a;


ll solve_slow(){
    ll rs = 0;
    for(int i = 0; i < n; i += 1){
        vector<int> t = {a[i]};
        rs += a[i];
        for(int j = i + 1; j < n; j += 1){
            ll x = a[j];
            while(t.size() > 1 && t[t.size() - 2] <= x){
                t.pop_back();
                t.back() += 1;
            }
            ll y = t.back();
            if(y <= x){
                t.pop_back();
                t.push_back(x + 1);
            } else{
                t.push_back(x);
            }
            while(t.size() > 1 && t.back() == t[t.size() - 2]){
                t.pop_back();
                t.back() += 1;
            }
            if(t.size() == 1){
                rs += t[0];
            } else{
                rs += t[0] + 1;
            }
        }
    }
    return rs;
}


int32_t main(){
    if(!local){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }
    ll t = 1;
    if(local){
        t = 1e6;
    }
    while(t--){
        cin >> n;
        assert(n <= 5000);
        a.resize(n);
        for(int i = 0; i < n; i += 1){
            cin >> a[i];
        }
        cout << solve_slow() << "\n";
    }
    return 0;
}

Details

In file included from /usr/include/c++/13/string:43,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from answer.code:6:
/usr/include/c++/13/bits/allocator.h: In destructor ‘std::_Vector_base<int, std::allocator<int> >::_Vector_impl::~_Vector_impl()’:
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = int]’: target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/queue:63,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:157:
/usr/include/c++/13/bits/stl_vector.h:133:14: note: called from here
  133 |       struct _Vector_impl
      |              ^~~~~~~~~~~~