Submission #1136194

#TimeUsernameProblemLanguageResultExecution timeMemory
1136194monaxiaPo (COCI21_po)C++20
30 / 70
7 ms840 KiB
#include <bits/stdc++.h> #define pb push_back #define ppb pop_back #define fr first #define sc second #define all(v) v.begin(), v.end() #define mod (long long)(1e9 + 7) #define eps (long long)(1e-9) #define vektor vector using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; const ull Mod = 1e9 + 7; const ll LIMIT = 2e5; void solve(){ int n, ans = 0; cin >> n; stack <int> s; vector <int> a(n + 1); for(int i = 1; i <= n; i ++) cin >> a[i]; for(int i = 1; i <= n; i ++){ if(!a[i]) continue; while(!s.empty() && s.top() > a[i]){ ans ++; s.pop(); } if(!s.empty() && s.top() == a[i]){ ans ++; s.pop(); } else s.push(a[i]); } ans += s.size(); cout << ans; } signed main() { cin.tie(0)->sync_with_stdio(0); // if(fopen("nameholder.inp", "r")){ // freopen("nameholder.inp", "r", stdin); // freopen("nameholder.out", "w", stdout); // } // cout << 1; return 0; ll n = 1; // cin >> n; while(n) { solve(); n --; cout << "\n"; } // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; return 0; } // ++++ // ++++-::......:--:::-=+++ // ++++=:............---.....--:..:=++++++ // +++++++::......................::=+++++ // @@ ++++++++++:+++++++++ // @% @* // %%@@ *****#*@@ // %%%%% @##**##***% // @@@@@@+-*#*@ #####%+*##*@ // %#+@%%@@@ ##-%:::-#*###@@ // =====:*::: ###-:==::=#*%* // -====:::::+@@%@@%@#*--=*#%%#@%@ @%@ // @=====%=-@%=:::.:+-::::+::::::::::::%-----%% @@@@@ // @@%#*@++%===+::-================@%@@@@+++++++@@@%%%@#%###% // @#***#@@ @##=%@===+--:+==+===+%*##@%%%@@@@@@@@@@:= @%@%%%@#%% // -@ @*#@ #####%:::-====+:::==---**%#@ *%%%%@@@@@@-: // -=-*% # #***--%%::::::::+=-+#-----=**@*# #+**#@# // ----=----#+****=----=*#@=::::::=#-----------***%*% // ------------%*****##=@==::::::+%-----------***%** // +-----------------*@++%::::::::-----------****@*# // =------------% @%=+%#+:::::::* #-----*--**** ** // ----%--% *==+++++=+=##*:% ---=--**** ** // %@@@@@@@@@==@+%%%%@ ----**** *# // @=*+%@@@%@@=++=:%:::% #***@@# // #+++++++++#==++-:::::: @**** *# // =+++++++++++==+++::::::: ####@ #% // +++++++++++=@ @++++::::::@ @# // @+++++++++=@ =*++=:::::@ // ++++++++@ @++++::::: // ++++++= =++++::: // =+++++@ =+++:::: // ++++++-@ =+++:+:: // @::+::::@ =++::-::: // +::=::::: @+*+:-+++-: // @::+-:::::# +++::::::@ // ::%=:::::::%@ @%++::::*** // @:+@*:::::::****@ +@+++:-=*:*@ // *:@@%::::::::=**** @%@+++:::#**@ // *%@@@-:::::::%=+==*@ +@%+++:***+* // #%@@%%::::::::#+=-=# =+@+++++:::*+ // @####+::::::::%+=@#%#=@ @**@@%=++::::@ // @ +:::::::::***#*@ @@###+=+=%@ +**#+=+*+:::- // =-:::::::%%%%@@ @#=*########%#+*%%+--@*+::% // +---%@ @@ =-:-**:# // %%%%% @+--*@ // @%%%%@ @%%%%% // @%%@@
#Verdict Execution timeMemoryGrader output
Fetching results...