結果
問題 | No.2927 Reverse Polish Equation |
ユーザー | Andrew8128 |
提出日時 | 2024-10-12 15:37:58 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,724 bytes |
コンパイル時間 | 3,034 ms |
コンパイル使用メモリ | 255,560 KB |
実行使用メモリ | 11,348 KB |
最終ジャッジ日時 | 2024-10-16 00:23:15 |
合計ジャッジ時間 | 7,237 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
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 | 3 ms
5,248 KB |
testcase_12 | AC | 72 ms
5,248 KB |
testcase_13 | AC | 126 ms
6,144 KB |
testcase_14 | AC | 86 ms
5,376 KB |
testcase_15 | AC | 125 ms
6,016 KB |
testcase_16 | AC | 40 ms
5,248 KB |
testcase_17 | AC | 160 ms
7,040 KB |
testcase_18 | AC | 194 ms
8,064 KB |
testcase_19 | AC | 14 ms
5,248 KB |
testcase_20 | AC | 156 ms
6,912 KB |
testcase_21 | AC | 243 ms
9,088 KB |
testcase_22 | AC | 24 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 | 1 ms
5,248 KB |
testcase_27 | AC | 214 ms
8,320 KB |
testcase_28 | AC | 174 ms
7,552 KB |
testcase_29 | AC | 23 ms
5,248 KB |
testcase_30 | AC | 201 ms
7,936 KB |
testcase_31 | AC | 15 ms
5,248 KB |
testcase_32 | AC | 48 ms
5,248 KB |
testcase_33 | AC | 88 ms
5,376 KB |
testcase_34 | AC | 106 ms
5,888 KB |
testcase_35 | AC | 2 ms
5,248 KB |
testcase_36 | AC | 202 ms
8,192 KB |
testcase_37 | AC | 7 ms
5,248 KB |
testcase_38 | AC | 20 ms
8,832 KB |
testcase_39 | AC | 100 ms
5,504 KB |
testcase_40 | AC | 18 ms
7,936 KB |
testcase_41 | AC | 165 ms
7,040 KB |
testcase_42 | WA | - |
testcase_43 | AC | 116 ms
11,216 KB |
testcase_44 | AC | 131 ms
11,348 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(100000000000005LL); }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 = 100000000000005LL; 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 */