結果
問題 | No.2698 Many Asakatsu |
ユーザー | KowerKoint2010 |
提出日時 | 2024-03-16 17:28:22 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 7,235 bytes |
コンパイル時間 | 3,000 ms |
コンパイル使用メモリ | 264,712 KB |
実行使用メモリ | 15,780 KB |
最終ジャッジ日時 | 2024-09-30 04:07:31 |
合計ジャッジ時間 | 8,237 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
13,640 KB |
testcase_01 | AC | 1 ms
6,820 KB |
testcase_02 | AC | 2 ms
6,820 KB |
testcase_03 | AC | 1 ms
6,820 KB |
testcase_04 | AC | 2 ms
6,816 KB |
testcase_05 | AC | 2 ms
6,820 KB |
testcase_06 | AC | 1 ms
6,816 KB |
testcase_07 | AC | 2 ms
6,816 KB |
testcase_08 | AC | 2 ms
6,820 KB |
testcase_09 | AC | 2 ms
6,816 KB |
testcase_10 | AC | 2 ms
6,820 KB |
testcase_11 | AC | 27 ms
6,820 KB |
testcase_12 | AC | 28 ms
6,816 KB |
testcase_13 | AC | 21 ms
6,820 KB |
testcase_14 | AC | 35 ms
6,824 KB |
testcase_15 | AC | 12 ms
6,816 KB |
testcase_16 | AC | 19 ms
6,820 KB |
testcase_17 | AC | 5 ms
6,816 KB |
testcase_18 | AC | 49 ms
6,816 KB |
testcase_19 | AC | 218 ms
6,820 KB |
testcase_20 | AC | 211 ms
6,816 KB |
testcase_21 | AC | 300 ms
6,816 KB |
testcase_22 | TLE | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
ソースコード
#line 2 "/home/kowerkoint/workspace/CompPro-Make/library/KowerKoint/stl-expansion.hpp" #include <bits/stdc++.h> template <typename T1, typename T2> std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) { is >> p.first >> p.second; return is; } template <typename T, size_t N> std::istream& operator>>(std::istream& is, std::array<T, N>& a) { for (size_t i = 0; i < N; ++i) { is >> a[i]; } return is; } template <typename T> std::istream& operator>>(std::istream& is, std::vector<T>& v) { for (auto& e : v) is >> e; return is; } template <typename T1, typename T2> std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p) { os << p.first << " " << p.second; return os; } template <typename T, size_t N> std::ostream& operator<<(std::ostream& os, const std::array<T, N>& a) { for (size_t i = 0; i < N; ++i) { os << a[i] << (i + 1 == a.size() ? "" : " "); } return os; } template <typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) { for (size_t i = 0; i < v.size(); ++i) { os << v[i] << (i + 1 == v.size() ? "" : " "); } return os; } #line 3 "/home/kowerkoint/workspace/CompPro-Make/library/KowerKoint/base.hpp" using namespace std; #define REP(i, n) for(int i = 0; i < (int)(n); i++) #define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++) #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() #define END(...) { print(__VA_ARGS__); return; } template <typename T> inline auto rep(T n) { return views::iota(T(0), n); } template <typename T> inline auto rep(T st, T ed, T step = 1) { return views::iota(T(0), (ed - st) / step) | views::transform([st, step](T i) { return st + i * step; }); } using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>; using ll = long long; using VL = vector<ll>; using VVL = vector<VL>; using VVVL = vector<VVL>; using ull = unsigned long long; using VUL = vector<ull>; using VVUL = vector<VUL>; using VVVUL = vector<VVUL>; using VD = vector<double>; using VVD = vector<VD>; using VVVD = vector<VVD>; using VS = vector<string>; using VVS = vector<VS>; using VVVS = vector<VVS>; using VC = vector<char>; using VVC = vector<VC>; using VVVC = vector<VVC>; using P = pair<int, int>; using VP = vector<P>; using VVP = vector<VP>; using VVVP = vector<VVP>; using LP = pair<ll, ll>; using VLP = vector<LP>; using VVLP = vector<VLP>; using VVVLP = vector<VVLP>; template <typename T> using PQ = priority_queue<T>; template <typename T> using GPQ = priority_queue<T, vector<T>, greater<T>>; constexpr int INF = 1001001001; constexpr ll LINF = 1001001001001001001ll; constexpr int DX[] = {1, 0, -1, 0}; constexpr int DY[] = {0, 1, 0, -1}; void print() { cout << '\n'; } template<typename T> void print(const T &t) { cout << t << '\n'; } template<typename Head, typename... Tail> void print(const Head &head, const Tail &... tail) { cout << head << ' '; print(tail...); } #ifdef DEBUG void dbg() { cerr << '\n'; } template<typename T> void dbg(const T &t) { cerr << t << '\n'; } template<typename Head, typename... Tail> void dbg(const Head &head, const Tail &... tail) { cerr << head << ' '; dbg(tail...); } #else template<typename... Args> void dbg(const Args &... args) {} #endif template<typename T> vector<vector<T>> split(typename vector<T>::const_iterator begin, typename vector<T>::const_iterator end, T val) { vector<vector<T>> res; vector<T> cur; for(auto it = begin; it != end; it++) { if(*it == val) { res.push_back(cur); cur.clear(); } else cur.push_back(*it); } res.push_back(cur); return res; } vector<string> split(typename string::const_iterator begin, typename string::const_iterator end, char val) { vector<string> res; string cur = ""; for(auto it = begin; it != end; it++) { if(*it == val) { res.push_back(cur); cur.clear(); } else cur.push_back(*it); } res.push_back(cur); return res; } template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); } template <typename T> pair<VI, vector<T>> compress(const vector<T> &a) { int n = a.size(); vector<T> x; REP(i, n) x.push_back(a[i]); sort(ALL(x)); x.erase(unique(ALL(x)), x.end()); VI res(n); REP(i, n) res[i] = lower_bound(ALL(x), a[i]) - x.begin(); return make_pair(res, x); } template <typename It> auto rle(It begin, It end) { vector<pair<typename It::value_type, int>> res; if(begin == end) return res; auto pre = *begin; int num = 1; for(auto it = begin + 1; it != end; it++) { if(pre != *it) { res.emplace_back(pre, num); pre = *it; num = 1; } else num++; } res.emplace_back(pre, num); return res; } template <typename It> vector<pair<typename It::value_type, int>> rle_sort(It begin, It end) { vector<typename It::value_type> cloned(begin, end); sort(ALL(cloned)); auto e = rle(ALL(cloned)); sort(ALL(e), [](const auto& l, const auto& r) { return l.second < r.second; }); return e; } template <typename T> pair<vector<T>, vector<T>> factorial(int n) { vector<T> res(n+1), rev(n+1); res[0] = 1; REP(i, n) res[i+1] = res[i] * (i+1); rev[n] = 1 / res[n]; for(int i = n; i > 0; i--) { rev[i-1] = rev[i] * i; } return make_pair(res, rev); } #line 2 "main.cpp" void solve(){ ll n, m; cin >> n >> m; VL a(n), b(n); REP(i, n) cin >> a[i] >> b[i]; auto get_y = [&](ll i, ll x) { if(b[i] == 0) return abs(x-a[i]) * m; ll j = x < a[i] ? 0 : min(m, ((x-a[i])/b[i]) + 1); return (-m+2*j) * (x - (a[i]+j*b[i])) + (j*j - (m-1)*j + m*(m-1)/2) * b[i]; }; VL ps(n); REP(i, n) ps[i] = a[i]*2 + (m-1)*b[i]; VI bsort(n); iota(ALL(bsort), 0); sort(ALL(bsort), [&](int i, int j) { return b[i] < b[j]; }); VI is_small_b(n); int pick = min(n, 1000LL); REP(i, pick) { is_small_b[bsort[i]] = 1; } ll q; cin >> q; ll x; cin >> x; VL c(n); cin >> c; VL ans(q); REP(i, q) { VI check(bsort.begin(), bsort.begin()+pick); int r = lower_bound(ALL(ps), x*2) - ps.begin(); int l = r-1; while(l >= 0 || r < n) { int nxt = -1; if(l < 0) { nxt = r++; } else if(r >= n) { nxt = l--; } else if(abs(x*2 - ps[l]) < abs(x*2 - ps[r])) { nxt = l--; } else { nxt = r++; } if(is_small_b[nxt]) break; check.push_back(nxt); } pair<ll, int> tmp(LINF, -1); for(int c : check) chmin(tmp, pair<ll, int>(get_y(c, x), c)); x += c[tmp.second]; ans[i] = tmp.second + 1; } print(ans); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(10); int t = 1; // cin >> t; for(int case_id = 1; case_id <= t; case_id++) solve(); return 0; }