結果
| 問題 |
No.808 Kaiten Sushi?
|
| コンテスト | |
| ユーザー |
momohara
|
| 提出日時 | 2020-08-29 17:47:32 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,801 bytes |
| コンパイル時間 | 2,422 ms |
| コンパイル使用メモリ | 202,016 KB |
| 最終ジャッジ日時 | 2025-01-13 20:29:44 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 46 RE * 10 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
using tp = tuple<ll, ll, ll>;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll)1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T>
inline bool chmin(T &a, T b) {
if(a > b) {
a = b;
return true;
}
return false;
}
template <class T>
inline bool chmax(T &a, T b) {
if(a < b) {
a = b;
return true;
}
return false;
}
//グラフ関連
struct Edge {
ll to, cap, rev;
Edge(ll _to, ll _cap, ll _rev) {
to = _to;
cap = _cap;
rev = _rev;
}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
G[from].push_back(Edge(to, cap, (ll)G[to].size()));
if(revFlag)
G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}
void solve() {
ll n, l;
cin >> n >> l;
vec<ll> x(n);
vec<ll> y(n);
set<ll> stx, sty;
REP(i, n) {
cin >> x[i];
stx.insert(x[i]);
}
REP(i, n) {
cin >> y[i];
sty.insert(y[i]);
}
auto it = stx.begin();
ll ans = 0;
ll t = 0;
while(stx.size()) {
//次のお茶
auto sy = sty.upper_bound(*it);
if(sy == sty.end()) {
sy = sty.begin();
t++;
}
//次のお茶より後にある寿司
auto tx = stx.upper_bound(*sy);
if(tx == stx.end()) {
tx = stx.begin();
t++;
}
//効率を落とさずに最後に飲めるお茶
auto ty = sty.upper_bound(*tx);
if(ty == sty.begin())
ty = sty.end();
ty--;
if(stx.size() == 1) {
if(*it < *ty)
t--;
cout << l * t + *ty << en;
return;
}
sty.erase(ty); //最後のお茶をのむ
if(*it == *tx) {
it = stx.erase(it);
} else {
stx.erase(it);
it = tx; //次の寿司
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
/*
ll t;
cin >> t;
while(t--)*/
solve();
return 0;
}
momohara