結果
問題 | No.2453 Seat Allocation |
ユーザー | Aeren |
提出日時 | 2023-09-01 22:28:16 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 99 ms / 2,000 ms |
コード長 | 4,589 bytes |
コンパイル時間 | 4,157 ms |
コンパイル使用メモリ | 365,320 KB |
実行使用メモリ | 10,240 KB |
最終ジャッジ日時 | 2024-06-25 09:28:21 |
合計ジャッジ時間 | 6,312 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 87 ms
10,240 KB |
testcase_06 | AC | 27 ms
5,376 KB |
testcase_07 | AC | 38 ms
9,856 KB |
testcase_08 | AC | 8 ms
5,376 KB |
testcase_09 | AC | 99 ms
10,240 KB |
testcase_10 | AC | 99 ms
10,240 KB |
testcase_11 | AC | 97 ms
10,240 KB |
testcase_12 | AC | 28 ms
5,376 KB |
testcase_13 | AC | 32 ms
5,376 KB |
testcase_14 | AC | 25 ms
5,376 KB |
testcase_15 | AC | 40 ms
5,376 KB |
testcase_16 | AC | 33 ms
5,376 KB |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | AC | 57 ms
6,400 KB |
testcase_19 | AC | 79 ms
8,576 KB |
testcase_20 | AC | 34 ms
5,688 KB |
testcase_21 | AC | 34 ms
5,376 KB |
testcase_22 | AC | 50 ms
5,376 KB |
testcase_23 | AC | 2 ms
5,376 KB |
testcase_24 | AC | 2 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> #include <x86intrin.h> using namespace std; using namespace numbers; template<class T> struct field_of_fraction{ static field_of_fraction limit_min(){ return {-1, 0}; } static field_of_fraction limit_max(){ return {1, 0}; } T n, d; field_of_fraction(T n = 0, T d = 1): n(n), d(d){ if(d < 0) this->n = -n, this->d = -d; } field_of_fraction &reduce(){ T g = gcd(n, d); n /= g, d /= g; return *this; } field_of_fraction reduced() const{ return field_of_fraction(*this).reduce(); } field_of_fraction &operator+=(const field_of_fraction &x){ return *this = {n * x.d + x.n * d, d * x.d}; } field_of_fraction &operator+=(const T &x){ return *this = {n + d * x, d}; } field_of_fraction &operator-=(const field_of_fraction &x){ return *this = {n * x.d - x.n * d, d * x.d}; } field_of_fraction &operator-=(const T &x){ return *this = {n - d * x, d}; } field_of_fraction &operator*=(const field_of_fraction &x){ return *this = {n * x.n, d * x.d}; } field_of_fraction &operator*=(const T &x){ return *this = {n * x, d}; } field_of_fraction &operator/=(const field_of_fraction &x){ assert(x.n != T(0)); return *this = {n * x.d, d * x.n}; } field_of_fraction &operator/=(const T &x){ assert(x != T(0)); return *this = {n, d * x}; } friend ostream &operator<<(ostream &out, const field_of_fraction &x){ return out << x.n << "/" << x.d; } field_of_fraction operator+(const field_of_fraction &x) const{ return field_of_fraction(*this) += x; } field_of_fraction operator+(const T &x) const{ return field_of_fraction(*this) += x; } friend field_of_fraction operator+(const T &x, const field_of_fraction &f){ return field_of_fraction(f) += x; } field_of_fraction operator+() const{ return *this; } field_of_fraction operator-(const field_of_fraction &x) const{ return field_of_fraction(*this) -= x; } field_of_fraction operator-(const T &x) const{ return field_of_fraction(*this) -= x; } friend field_of_fraction operator-(const T &x, const field_of_fraction &f){ return {x * f.d - f.n, f.d}; } field_of_fraction operator-() const{ return {-n, d}; } field_of_fraction operator*(const field_of_fraction &x) const{ return field_of_fraction(*this) *= x; } field_of_fraction operator*(const T &x) const{ return field_of_fraction(*this) *= x; } friend field_of_fraction operator*(const T &x, const field_of_fraction &f){ return field_of_fraction(f) *= x; } field_of_fraction operator/(const field_of_fraction &x) const{ return field_of_fraction(*this) /= x; } field_of_fraction operator/(const T &x) const{ return field_of_fraction(*this) /= x; } friend field_of_fraction operator/(const T &x, const field_of_fraction &f){ return field_of_fraction(x * f.d, f.n); } field_of_fraction &operator++(){ n += d; return *this; } field_of_fraction operator++(int){ auto res = *this; n += d; return res; } field_of_fraction &operator--(){ n -= d; return *this; } field_of_fraction operator--(int){ auto res = *this; n -= d; return res; } #define OP(c)\ bool operator c(const field_of_fraction &x) const{\ return n * x.d c x.n * d;\ } OP(==) OP(!=) OP(<) OP(<=) OP(>) OP(>=) #undef OP #define OP(c)\ bool operator c(const T &x) const{\ return n c d * x;\ } OP(==) OP(!=) OP(<) OP(<=) OP(>) OP(>=) #undef OP #define OP(c)\ friend bool operator c(const T &x, const field_of_fraction &f){\ return f.d * x c f.n;\ } OP(==) OP(!=) OP(<) OP(<=) OP(>) OP(>=) #undef OP }; using F = field_of_fraction<long long>; int main(){ cin.tie(0)->sync_with_stdio(0); cin.exceptions(ios::badbit | ios::failbit); int n, m; cin >> n >> m; vector<int> a(n), b(m); copy_n(istream_iterator<int>(cin), n, a.begin()); copy_n(istream_iterator<int>(cin), m, b.begin()); set<pair<F, array<int, 2>>, greater<>> s; for(auto i = 0; i < n; ++ i){ s.insert({F{a[i], b[0]}, {-i, 0}}); } for(auto rep = m; rep; -- rep){ auto [f, info] = *s.begin(); auto [i, j] = info; i = -i; s.erase(s.begin()); cout << i + 1 << "\n"; if(j + 1 < m){ s.insert({F{a[i], b[j + 1]}, {-i, j + 1}}); } } return 0; } /* */ //////////////////////////////////////////////////////////////////////////////////////// // // // Coded by Aeren // // // ////////////////////////////////////////////////////////////////////////////////////////