結果
問題 | No.1650 Moving Coins |
ユーザー | yuji9511 |
提出日時 | 2021-08-20 22:12:16 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,855 bytes |
コンパイル時間 | 2,006 ms |
コンパイル使用メモリ | 207,120 KB |
実行使用メモリ | 8,476 KB |
最終ジャッジ日時 | 2024-10-14 03:58:01 |
合計ジャッジ時間 | 7,508 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,248 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 39 ms
7,008 KB |
testcase_09 | WA | - |
testcase_10 | AC | 39 ms
7,076 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 57 ms
8,476 KB |
testcase_21 | WA | - |
testcase_22 | AC | 56 ms
8,476 KB |
testcase_23 | AC | 55 ms
8,460 KB |
testcase_24 | AC | 19 ms
5,348 KB |
testcase_25 | AC | 19 ms
5,476 KB |
testcase_26 | AC | 37 ms
6,272 KB |
ソースコード
/*** author: yuji9511 ***/ #include <bits/stdc++.h> // #include <atcoder/all> // using namespace atcoder; using namespace std; using ll = long long; using lpair = pair<ll, ll>; using vll = vector<ll>; const ll MOD = 1e9+7; const ll INF = 1e18; #define rep(i,m,n) for(ll i=(m);i<(n);i++) #define rrep(i,m,n) for(ll i=(m);i>=(n);i--) ostream& operator<<(ostream& os, lpair& h){ os << "(" << h.first << ", " << h.second << ")"; return os;} #define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];}; void print() {} template <class H,class... T> void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);} template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } void solve(){ ll N; cin >> N; vll A(N), B(N); rep(i,0,N) cin >> A[i]; rep(i,0,N) cin >> B[i]; ll idx = -1; vector<pair<int, char> > ans; rep(i,0,N){ bool ok = false; if(i == 0){ if(B[i] <= A[i]) ok = true; }else{ if(B[i] > A[i-1]) ok = true; } if(i == N-1){ if(B[i] >= A[i]) ok = true; }else{ if(B[i] < A[i+1]) ok = true; } if(ok){ idx = i; break; } } assert(idx != -1); rrep(i,idx,0){ ll diff = A[i] - B[i]; if(diff > 0){ rep(n,0,diff){ ans.push_back({i+1, 'L'}); } }else{ rep(n,0,-diff){ ans.push_back({i+1, 'R'}); } } } rep(i,idx+1,N){ ll diff = A[i] - B[i]; if(diff > 0){ rep(n,0,diff){ ans.push_back({i+1, 'L'}); } }else{ rep(n,0,-diff){ ans.push_back({i+1, 'R'}); } } } print(ans.size()); for(auto &e: ans){ print(e.first, e.second); } } int main(){ cin.tie(0); ios::sync_with_stdio(false); solve(); }