結果
問題 | No.1650 Moving Coins |
ユーザー | kaede2020 |
提出日時 | 2021-08-21 07:39:13 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 413 ms / 2,000 ms |
コード長 | 3,280 bytes |
コンパイル時間 | 4,262 ms |
コンパイル使用メモリ | 238,436 KB |
実行使用メモリ | 10,736 KB |
最終ジャッジ日時 | 2024-04-22 17:09:58 |
合計ジャッジ時間 | 16,151 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
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 | 264 ms
5,376 KB |
testcase_04 | AC | 208 ms
5,452 KB |
testcase_05 | AC | 246 ms
5,456 KB |
testcase_06 | AC | 272 ms
5,704 KB |
testcase_07 | AC | 273 ms
5,712 KB |
testcase_08 | AC | 341 ms
8,332 KB |
testcase_09 | AC | 343 ms
8,160 KB |
testcase_10 | AC | 342 ms
8,236 KB |
testcase_11 | AC | 348 ms
7,548 KB |
testcase_12 | AC | 323 ms
6,756 KB |
testcase_13 | AC | 324 ms
6,736 KB |
testcase_14 | AC | 349 ms
7,328 KB |
testcase_15 | AC | 310 ms
6,516 KB |
testcase_16 | AC | 363 ms
7,824 KB |
testcase_17 | AC | 352 ms
7,596 KB |
testcase_18 | AC | 376 ms
7,916 KB |
testcase_19 | AC | 402 ms
10,732 KB |
testcase_20 | AC | 408 ms
10,736 KB |
testcase_21 | AC | 413 ms
9,604 KB |
testcase_22 | AC | 404 ms
9,712 KB |
testcase_23 | AC | 401 ms
9,840 KB |
testcase_24 | AC | 280 ms
5,452 KB |
testcase_25 | AC | 279 ms
5,452 KB |
testcase_26 | AC | 129 ms
5,376 KB |
ソースコード
/*#include <iostream> // cout, endl, cin #include <string> // string, to_string, stoi #include <vector> // vector #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <utility> // pair, make_pair #include <tuple> // tuple, make_tuple #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <map> // map #include <queue> // queue, priority_queue #include <set> // set #include <stack> // stack #include <deque> // deque #include <unordered_map> // unordered_map #include <unordered_set> // unordered_set #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower #include <iomanip>//fixed,setprecision #include <limits.n>//INT_MAX #include <math.n>//M_PI #include <random> #include <time.h>*/ #include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; //using mint = modint1000000007; using mint = modint998244353; //std::chrono::time_point<std::chrono::steady_clock> start; template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; } template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; } #define ll long long #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) typedef pair<ll, int> P; using vi=vector<int>; using vvi=vector<vi>; ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } ll lcm(ll a, ll b){return a * b / gcd(a, b);} template<class T, class U> //contain(string s,string v) sにvが含まれるかを判定 bool contain(const std::basic_string<T>& s, const U& v) { return s.find(v) != std::basic_string<T>::npos; } const int mod=1000000007; struct combination { vector<mint> fact, ifact; combination(int n):fact(n+1),ifact(n+1) { assert(n < mod); fact[0] = 1; for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i; ifact[n] = fact[n].inv(); for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i; } mint operator()(int n, int k) { if (k < 0 || k > n) return 0; return fact[n]*ifact[k]*ifact[n-k]; } }; int main(){ int n; cin>>n; vector<int>a(n),b(n); rep(i,n)cin>>a[i]; rep(i,n)cin>>b[i]; int start=-1; vector<tuple<int,int,char>>ans_l,ans_r; rep(i,n){ if(a[i]==b[i])continue; else if(a[i]<b[i])ans_r.emplace_back(i,b[i]-a[i],'R'); else ans_l.emplace_back(i,a[i]-b[i],'L'); } vector<pair<int,char>>kotae_l,kotae_r; if(ans_l.size()==0&&ans_r.size()==0)cout<<0<<endl; else{ rep(i,ans_l.size()){ int gyo=get<0>(ans_l[i])+1; int num=get<1>(ans_l[i]); char muki=get<2>(ans_l[i]); rep(j,num){ //cout<<gyo<<" "<<muki<<endl; kotae_l.emplace_back(gyo,muki); } } sort(kotae_l.begin(),kotae_l.end()); rep(i,ans_r.size()){ int gyo=get<0>(ans_r[i])+1; int num=get<1>(ans_r[i]); char muki=get<2>(ans_r[i]); rep(j,num){ //cout<<gyo<<" "<<muki<<endl; kotae_r.emplace_back(gyo,muki); } } sort(kotae_r.rbegin(),kotae_r.rend()); cout<<kotae_l.size()+kotae_r.size()<<endl; rep(i,kotae_l.size()){ cout<<kotae_l[i].first<<" "<<kotae_l[i].second<<endl; } rep(i,kotae_r.size()){ cout<<kotae_r[i].first<<" "<<kotae_r[i].second<<endl; } } return 0; }