QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#881350#10050. Bitaro the Brave 2Mousa_AboubakerCompile Error//C++202.6kb2025-02-04 15:08:422025-02-04 15:08:42

Judging History

This is the latest submission verdict.

  • [2025-02-04 15:08:42]
  • Judged
  • [2025-02-04 15:08:42]
  • Submitted

answer

#pragma GCC optimize("O3", "Ofast", "unroll-loops")
#pragma GCC target("popcnt")
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <deque>
#include <climits>
#include <cmath>
#include <numeric>
#include <string>
#include <bitset>
#include <assert.h>
#include <iomanip>
#include <bit>
using namespace std;

template <typename T>
using pqg = priority_queue<T, vector<T>, greater<T>>;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/
/*
#include <bits/stdc++.h>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define getrand(l, r) uniform_int_distribution<int>(l, r)(rng)
*/

const long long infl = 1e18 + 1;
const int inf = 1e9 + 1;
const int mod1 = 1e9 + 7;
const int mod2 = 998244353;
const long double eps = 1e-7;
const int mod = mod1;

int add(int a, int b) { return (a + b) % mod; }
int sub(int a, int b) { return (a - b + mod) % mod; }
int mul(int a, int b) { return (int)((long long)a * b % mod); }
int pwr(int a, int b = mod - 2)
{
  int res = 1;
  for (; b > 0; b >>= 1, a = mul(a, a))
    if (b & 1)
      res = mul(res, a);
  return res;
}
template <typename T>
bool chmax(T &a, T b)
{
  if (b > a)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, T b)
{
  if (b < a)
  {
    a = b;
    return true;
  }
  return false;
}

#define all(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define vec vector
using ll = long long;

void solve()
{
  int n;
  cin >> n;
  vec<int> a(n), b(n);
  for(auto &i: a)
    cin >> i;
  for(auto &i: b)
    cin >> i;
  vec<ll> pref(n);
  for(int i = 0; i < n; i++)
  {
    if(i)
      pref[i] = pref[i - 1];
    pref[i] += b[i];
  }
  multiset<ll> st;
  st.insert(a[0]);
  for(int i = 1; i < n; i++)
    st.insert(a[i] - pref[i - 1]);
  long long sum = 0;
  long long mn = infl;
  for(int i = 0; i < n; i++)
  {
    st.erase(st.find(a[i] - (i ? pref[i - 1] : 0)));
    long long curr = a[i];
    chmin(mn, max(curr, *prev(st.end()) + sum));
    sum += b[i];
    st.insert(a[i] - sum - (i ? pref[i - 1] : 0) - pref[n - 1] + pref[i]);
  }
  cout << mn;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int t = 1;
  // cin >> t;
  while (t--)
  {
    solve();
    cout << (t ? "\n" : "");
  }
}

詳細信息

In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from answer.code:3:
/usr/include/c++/14/bits/allocator.h: In destructor ‘constexpr std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::_Rb_tree_impl<std::less<long long int>, true>::~_Rb_tree_impl()’:
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to ‘always_inline’ ‘constexpr std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::_Rb_tree_node<long long int>]’: target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/set:62,
                 from answer.code:7:
/usr/include/c++/14/bits/stl_tree.h:658:16: note: called from here
  658 |         struct _Rb_tree_impl
      |                ^~~~~~~~~~~~~