結果
問題 | No.2694 The Early Bird Catches The Worm |
ユーザー | みしあ |
提出日時 | 2024-03-27 01:31:00 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 190 ms / 2,000 ms |
コード長 | 9,060 bytes |
コンパイル時間 | 6,189 ms |
コンパイル使用メモリ | 286,576 KB |
実行使用メモリ | 20,232 KB |
最終ジャッジ日時 | 2024-03-27 01:31:18 |
合計ジャッジ時間 | 17,403 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,548 KB |
testcase_01 | AC | 2 ms
6,548 KB |
testcase_02 | AC | 2 ms
6,548 KB |
testcase_03 | AC | 1 ms
6,548 KB |
testcase_04 | AC | 2 ms
6,548 KB |
testcase_05 | AC | 2 ms
6,548 KB |
testcase_06 | AC | 3 ms
6,548 KB |
testcase_07 | AC | 2 ms
6,548 KB |
testcase_08 | AC | 2 ms
6,548 KB |
testcase_09 | AC | 2 ms
6,548 KB |
testcase_10 | AC | 2 ms
6,548 KB |
testcase_11 | AC | 2 ms
6,548 KB |
testcase_12 | AC | 3 ms
6,548 KB |
testcase_13 | AC | 2 ms
6,548 KB |
testcase_14 | AC | 2 ms
6,548 KB |
testcase_15 | AC | 3 ms
6,548 KB |
testcase_16 | AC | 3 ms
6,548 KB |
testcase_17 | AC | 3 ms
6,548 KB |
testcase_18 | AC | 3 ms
6,548 KB |
testcase_19 | AC | 2 ms
6,548 KB |
testcase_20 | AC | 2 ms
6,548 KB |
testcase_21 | AC | 2 ms
6,548 KB |
testcase_22 | AC | 2 ms
6,548 KB |
testcase_23 | AC | 2 ms
6,548 KB |
testcase_24 | AC | 45 ms
6,548 KB |
testcase_25 | AC | 46 ms
6,548 KB |
testcase_26 | AC | 53 ms
6,548 KB |
testcase_27 | AC | 73 ms
7,040 KB |
testcase_28 | AC | 93 ms
11,408 KB |
testcase_29 | AC | 31 ms
6,548 KB |
testcase_30 | AC | 146 ms
13,976 KB |
testcase_31 | AC | 82 ms
8,572 KB |
testcase_32 | AC | 137 ms
10,072 KB |
testcase_33 | AC | 143 ms
11,456 KB |
testcase_34 | AC | 8 ms
6,548 KB |
testcase_35 | AC | 76 ms
8,144 KB |
testcase_36 | AC | 90 ms
8,064 KB |
testcase_37 | AC | 162 ms
12,828 KB |
testcase_38 | AC | 112 ms
12,256 KB |
testcase_39 | AC | 27 ms
6,548 KB |
testcase_40 | AC | 82 ms
8,908 KB |
testcase_41 | AC | 38 ms
6,548 KB |
testcase_42 | AC | 5 ms
6,548 KB |
testcase_43 | AC | 15 ms
6,548 KB |
testcase_44 | AC | 169 ms
14,724 KB |
testcase_45 | AC | 170 ms
17,676 KB |
testcase_46 | AC | 49 ms
6,548 KB |
testcase_47 | AC | 54 ms
7,028 KB |
testcase_48 | AC | 85 ms
8,008 KB |
testcase_49 | AC | 70 ms
9,864 KB |
testcase_50 | AC | 70 ms
9,864 KB |
testcase_51 | AC | 70 ms
9,992 KB |
testcase_52 | AC | 70 ms
9,864 KB |
testcase_53 | AC | 70 ms
9,992 KB |
testcase_54 | AC | 184 ms
15,412 KB |
testcase_55 | AC | 185 ms
15,476 KB |
testcase_56 | AC | 184 ms
15,556 KB |
testcase_57 | AC | 165 ms
11,392 KB |
testcase_58 | AC | 189 ms
18,716 KB |
testcase_59 | AC | 177 ms
13,052 KB |
testcase_60 | AC | 180 ms
13,364 KB |
testcase_61 | AC | 172 ms
12,452 KB |
testcase_62 | AC | 172 ms
12,140 KB |
testcase_63 | AC | 180 ms
13,612 KB |
testcase_64 | AC | 187 ms
19,648 KB |
testcase_65 | AC | 179 ms
13,780 KB |
testcase_66 | AC | 184 ms
15,396 KB |
testcase_67 | AC | 189 ms
20,232 KB |
testcase_68 | AC | 190 ms
19,452 KB |
testcase_69 | AC | 110 ms
10,504 KB |
testcase_70 | AC | 111 ms
10,376 KB |
testcase_71 | AC | 110 ms
10,248 KB |
testcase_72 | AC | 110 ms
9,992 KB |
testcase_73 | AC | 111 ms
10,248 KB |
testcase_74 | AC | 56 ms
7,408 KB |
testcase_75 | AC | 110 ms
10,504 KB |
コンパイルメッセージ
In file included from /boost_git/boost/config/header_deprecated.hpp:18, from /boost_git/boost/core/swap.hpp:19, from /boost_git/boost/optional/optional.hpp:33, from /boost_git/boost/optional.hpp:15, from /boost_git/boost/format/internals.hpp:21, from /boost_git/boost/format.hpp:38, from main.cpp:9: /boost_git/boost/config/pragma_message.hpp:24:34: note: '#pragma message: This header is deprecated. Use boost/core/invoke_swap.hpp instead.' 24 | # define BOOST_PRAGMA_MESSAGE(x) _Pragma(BOOST_STRINGIZE(message(x))) | ^~~~~~~ /boost_git/boost/config/header_deprecated.hpp:23:37: note: in expansion of macro 'BOOST_PRAGMA_MESSAGE' 23 | # define BOOST_HEADER_DEPRECATED(a) BOOST_PRAGMA_MESSAGE("This header is deprecated. Use " a " instead.") | ^~~~~~~~~~~~~~~~~~~~ /boost_git/boost/core/swap.hpp:26:1: note: in expansion of macro 'BOOST_HEADER_DEPRECATED' 26 | BOOST_HEADER_DEPRECATED("boost/core/invoke_swap.hpp") | ^~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#pragma region Macros #if defined(ONLINE_JUDGE) #include <atcoder/all> #endif #if defined(LOCAL) || defined(_DEBUG) #include "template.hpp" #else #include <bits/stdc++.h> #include <boost/format.hpp> using namespace std; #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #define O(...) #define OP(...) #define START() #define STOP() #define MEMORY() #define massert(x, msec) if(!(x)) {\ while(msec > chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now() - _MY_START_TIME).count()); \ cerr << "assert [" << __FUNCTION__ << ":" << to_string(__LINE__) << "] : " << string(#x) << el; exit(1);\ } /******************************************* マクロ等 **************************************************/ #define REP(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i) #define REPR(i, n) for(ll i=(n); i>=0; --i) #define FOR(i, n, m) for(ll i=(m), i##_len=(n); i<i##_len; ++i) #define EACH(i, v) for(auto&& i : v) #define ALL(x) (x).begin(),(x).end() #define ALLR(x) (x).rbegin(),(x).rend() #define FILL(v, h) memset((v), h, sizeof(v)) #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) vector<long long> __FREP_CNT_ARRAY; #define FREP(i, n) ;__FREP_CNT_ARRAY.push_back(n); REP(i, n) { #define FREPR(i, n) ;__FREP_CNT_ARRAY.push_back((n)+1); REPR(i, n) { #define FFOR(i, n, m) ;__FREP_CNT_ARRAY.push_back((n)-(m)); FOR(i, n, m) { #define FEACH(a, as) ;__FREP_CNT_ARRAY.push_back((as).size()); EACH(a, as) { #define THEN __FREP_CNT_ARRAY.back()--;} if(bool frep_tmp = !__FREP_CNT_ARRAY.back(); __FREP_CNT_ARRAY.pop_back(), frep_tmp) #define DPINIT(name) name; bool __SEEN_##name; #define DP(name) name;if(__SEEN_##name)return name;__SEEN_##name=true; template<class T, class U>bool chmax(T &a, const U &b) { if (a<(T)b) { a=(T)b; return 1; } return 0; } template<class T, class U>bool chmin(T &a, const U &b) { if (b<(T)a) { a=(T)b; return 1; } return 0; } #define cmp3(a, x, b) ((a) <= (x) && (x) < (b)) #define vec vector #define umap unordered_map #define uset unordered_set using ll = long long; using ull = unsigned long long; using ld = long double; using P = pair<ll, ll>; using Tup = tuple<ll, ll, ll>; using vl = vec<ll>; using vvl = vec<vl>; #define fi first #define se second #define pb push_back #define el '\n' constexpr ll INF = numeric_limits<ll>::max()/4-1; /******************************************* 入力 **************************************************/ template<class T> istream &operator>>(istream &stream, vec<T>& o){REP(i, o.size())stream >> o[i];return stream;} template<class T, class U> istream &operator>>(istream &stream, pair<T, U>& o){cin >> o.fi >> o.se; return stream;} namespace myinput { void input() {} template<class T, class... Ts> void input(T&& o, Ts&&... args){cin >> o;input(forward<Ts>(args)...);} void assign_vl(size_t) {}; template<class T, class... Ts> void assign_vl(size_t siz, T&& o, Ts&&... args){o.resize(siz);assign_vl(siz, forward<Ts>(args)...);} void input_horizon_sub(size_t) {}; template<class T, class... Ts> void input_horizon_sub(size_t index, T&& o, Ts&&... args) {cin>>o[index];input_horizon_sub(index, forward<Ts>(args)...);} template<class... Ts> void input_horizon(size_t siz, Ts&&... args){REP(i, siz) input_horizon_sub(i, forward<Ts>(args)...);} } #define _I(T, ...) ;myinput::input(__VA_ARGS__); #define I(T, ...) ;T __VA_ARGS__;_I(T, __VA_ARGS__); #define _Iv(T, siz, ...) ;myinput::assign_vl(siz, __VA_ARGS__);myinput::input(__VA_ARGS__); #define Iv(T, siz, ...) ;vec<T> __VA_ARGS__;_Iv(T, siz, __VA_ARGS__); #define _Ih(T, siz, ...) ;myinput::assign_vl(siz, __VA_ARGS__);myinput::input_horizon(siz, __VA_ARGS__); #define Ih(T, siz, ...) ;vec<T> __VA_ARGS__;_Ih(T, siz, __VA_ARGS__); chrono::system_clock::time_point _MY_START_TIME; /******************************************* 出力 **************************************************/ namespace __PrintHelper { template <char Separator = ' ', typename T> void printValue(std::ostream& os, const T& value) { os << value; } template <char Separator = ' ', typename T1, typename T2> void printValue(std::ostream& os, const std::pair<T1, T2>& value) { os << value.first << Separator << value.second; } template <char Separator = ' ', typename... Args, std::size_t... Is> void printTuple(std::ostream& os, const std::tuple<Args...>& value, std::index_sequence<Is...>) { ((os << (Is == 0 ? "" : string(1, Separator)) << std::get<Is>(value)), ...); } template <char Separator = ' ', typename... Args> void printValue(std::ostream& os, const std::tuple<Args...>& value) { printTuple<Separator>(os, value, std::index_sequence_for<Args...>{}); } template <char Separator = ' ', typename T> void printValue(std::ostream& os, const std::vector<T>& value) { for (std::size_t i = 0; i < value.size(); ++i) os << (i == 0 ? "" : string(1, Separator)) << value[i]; } }; template <char Separator = ' ', typename Arg, typename... Args> void OO(const Arg &x, const Args&... args) { __PrintHelper::printValue<Separator>(cout, x); if constexpr (sizeof...(args) > 0) { cout << Separator; OO<Separator>(args...); } else { cout << el; } } template <class T = string, class U = string> void YN(bool x, T y = "Yes", U n = "No") { if(x) cout << y << el; else cout << n << el; } /******************************************* 配列操作 **************************************************/ namespace __ArrayHelper { template <typename... Args> auto flatten(const std::tuple<Args...>& t); template <typename T, std::size_t... Indices> auto flattenHelper(const T& t, std::index_sequence<Indices...>) { return std::make_tuple(std::get<Indices>(t)...); } template <typename T, typename U> auto flatten(const std::pair<T, U>& p) { return flatten(std::make_tuple(p.first, p.second)); } template <typename T> auto flatten(const T& value) { return std::make_tuple(value); } template <typename... Args, std::size_t... Indices> auto flattenTupleHelper(const std::tuple<Args...>& t, std::index_sequence<Indices...>) { return std::tuple_cat(flatten(std::get<Indices>(t))...); } template <typename... Args> auto flatten(const std::tuple<Args...>& t) { return flattenTupleHelper(t, std::index_sequence_for<Args...>{}); } template <typename Container> auto __flatten(const Container& container) { using ValueType = typename Container::value_type; using ResultType = decltype(__ArrayHelper::flatten(std::declval<ValueType>())); std::vector<ResultType> result; for (const auto& item : container) { result.emplace_back(__ArrayHelper::flatten(item)); } return result; } template <class T> auto __enumrate(const vec<T> &v) { vec<pair<ll, T>> ret(v.size()); REP(i, v.size()) ret[i] = {i, v[i]}; return ret; } } constexpr auto flatten = [](auto&& x) { return __ArrayHelper::__flatten(x); }; constexpr auto enumrate = [](auto&& x) { return __ArrayHelper::__enumrate(x); }; template <typename... Args> auto zip(const Args&... args) { size_t minSize = std::min({args.size()...}); std::vector<std::tuple<typename Args::value_type...>> result; for (size_t i = 0; i < minSize; ++i) { result.emplace_back(std::make_tuple(args[i]...)); } return result; } template <typename Arg> Arg compose(Arg arg) { return arg; } template <typename Arg, typename Func> auto compose(Arg arg, Func func) { return func(arg); } template <typename Arg, typename Func, typename... Funcs> auto compose(Arg arg, Func func, Funcs... funcs) { return compose(compose(arg, func), funcs...); } /******************************************* Main **************************************************/ #endif #pragma endregion using Point = complex<ll>; void Main(); int main(){ _MY_START_TIME = std::chrono::system_clock::now(); std::cin.tie(nullptr); std::cout << std::fixed << std::setprecision(15); std::cerr << std::fixed << std::setprecision(15); Main(); MEMORY(); return 0; } struct LS { queue<ll> q; ll value = 0; ll sum = 0; void push(ll x) { q.push(x); value += x * q.size(); sum += x; } void pop() { auto x = q.front(); q.pop(); value -= sum; sum -= x; } }; ll rec(ll h, vl &as, vl &bs) { LS ls; queue<ll> xs; ll sum = 0, mx = 0; REP(i, as.size()) { ls.push(bs[i]); xs.push(as[i]); sum += as[i]; while(ls.value > h) { ls.pop(); sum -= xs.front(); xs.pop(); } chmax(mx, sum); } return mx; } void Main() { I(ll, n, h); Iv(ll, n, as, bs); vvl aas(1), bbs(1); REP(i, n) { if(bs[i] > h) { aas.pb(vl()); bbs.pb(vl()); continue; } aas.back().pb(as[i]); bbs.back().pb(bs[i]); } ll mx = 0; O(aas, bbs); REP(i, aas.size()) { chmax(mx, rec(h, aas[i], bbs[i])); } OO(mx); }