結果
問題 | No.2927 Reverse Polish Equation |
ユーザー | Andrew8128 |
提出日時 | 2024-10-12 15:39:01 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,724 bytes |
コンパイル時間 | 3,322 ms |
コンパイル使用メモリ | 255,948 KB |
実行使用メモリ | 11,344 KB |
最終ジャッジ日時 | 2024-10-16 00:23:24 |
合計ジャッジ時間 | 7,477 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,248 KB |
testcase_03 | AC | 2 ms
5,248 KB |
testcase_04 | AC | 2 ms
5,248 KB |
testcase_05 | AC | 2 ms
5,248 KB |
testcase_06 | AC | 2 ms
5,248 KB |
testcase_07 | AC | 3 ms
5,248 KB |
testcase_08 | AC | 4 ms
5,248 KB |
testcase_09 | AC | 3 ms
5,248 KB |
testcase_10 | AC | 2 ms
5,248 KB |
testcase_11 | AC | 4 ms
5,248 KB |
testcase_12 | AC | 80 ms
5,248 KB |
testcase_13 | AC | 135 ms
6,272 KB |
testcase_14 | AC | 95 ms
5,376 KB |
testcase_15 | AC | 130 ms
6,144 KB |
testcase_16 | AC | 43 ms
5,248 KB |
testcase_17 | AC | 168 ms
7,168 KB |
testcase_18 | AC | 209 ms
7,936 KB |
testcase_19 | AC | 14 ms
5,248 KB |
testcase_20 | AC | 169 ms
6,912 KB |
testcase_21 | AC | 260 ms
9,088 KB |
testcase_22 | AC | 26 ms
5,248 KB |
testcase_23 | AC | 2 ms
5,248 KB |
testcase_24 | AC | 2 ms
5,248 KB |
testcase_25 | AC | 2 ms
5,248 KB |
testcase_26 | AC | 2 ms
5,248 KB |
testcase_27 | AC | 229 ms
8,320 KB |
testcase_28 | AC | 191 ms
7,424 KB |
testcase_29 | AC | 26 ms
5,248 KB |
testcase_30 | AC | 214 ms
7,936 KB |
testcase_31 | AC | 17 ms
5,248 KB |
testcase_32 | AC | 49 ms
5,248 KB |
testcase_33 | AC | 92 ms
5,248 KB |
testcase_34 | AC | 114 ms
5,760 KB |
testcase_35 | AC | 2 ms
5,248 KB |
testcase_36 | AC | 215 ms
8,064 KB |
testcase_37 | AC | 7 ms
5,248 KB |
testcase_38 | AC | 22 ms
8,832 KB |
testcase_39 | AC | 104 ms
5,504 KB |
testcase_40 | AC | 18 ms
7,936 KB |
testcase_41 | AC | 171 ms
7,168 KB |
testcase_42 | WA | - |
testcase_43 | AC | 124 ms
11,344 KB |
testcase_44 | AC | 138 ms
11,216 KB |
testcase_45 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i, x, y) for (auto i = (x); i < (y); i++) #define RREP(i, x, y) for (auto i = (y) - 1; (x) <= i; i--) #define ALL(x) (x).begin(), (x).end() #pragma GCC optimize("O3") int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ll Q, Y; cin >> Q >> Y; vector<string> S(Q); REP(i, 0, Q){ cin >> S[i]; } { vector<ll> A; REP(i, 0, Q){ if(S[i] == "X"){ A.push_back(110000000000000LL); }else if(S[i] == "+"){ ll tmp = A[ssize(A)-1] + A[ssize(A)-2]; A.pop_back(); A.pop_back(); A.push_back(tmp); }else if(S[i] == "min"){ ll tmp = min(A[ssize(A)-1], A[ssize(A)-2]); A.pop_back(); A.pop_back(); A.push_back(tmp); }else if(S[i] == "max"){ ll tmp = max(A[ssize(A)-1], A[ssize(A)-2]); A.pop_back(); A.pop_back(); A.push_back(tmp); }else{ A.push_back(stoll(S[i])); } } if(A[0] < Y){ cout << -1 << "\n"; return 0; } } ll l = -1, r = 110000000000000LL; while(1){ if(l + 1 == r)break; ll c = (l + r) / 2; vector<ll> A; REP(i, 0, Q){ if(S[i] == "X"){ A.push_back(c); }else if(S[i] == "+"){ ll tmp = A[ssize(A)-1] + A[ssize(A)-2]; A.pop_back(); A.pop_back(); A.push_back(tmp); }else if(S[i] == "min"){ ll tmp = min(A[ssize(A)-1], A[ssize(A)-2]); A.pop_back(); A.pop_back(); A.push_back(tmp); }else if(S[i] == "max"){ ll tmp = max(A[ssize(A)-1], A[ssize(A)-2]); A.pop_back(); A.pop_back(); A.push_back(tmp); }else{ A.push_back(stoll(S[i])); } } // cerr << c << " " << A[0] << "\n"; if(Y <= A[0]){ r = c; }else{ l = c; } // cerr << "l " << l << " r " << r << "\n"; } { vector<ll> A; REP(i, 0, Q){ if(S[i] == "X"){ A.push_back(r); }else if(S[i] == "+"){ ll tmp = A[ssize(A)-1] + A[ssize(A)-2]; A.pop_back(); A.pop_back(); A.push_back(tmp); }else if(S[i] == "min"){ ll tmp = min(A[ssize(A)-1], A[ssize(A)-2]); A.pop_back(); A.pop_back(); A.push_back(tmp); }else if(S[i] == "max"){ ll tmp = max(A[ssize(A)-1], A[ssize(A)-2]); A.pop_back(); A.pop_back(); A.push_back(tmp); }else{ A.push_back(stoll(S[i])); } } if(A[0] == Y){ cout << r << "\n"; }else{ cout << -1 << "\n"; } } return 0; } /* File : ~/yukicoder/midoriika_3rd/I.cpp Date : 2024/10/12 Time : 15:15:17 */