Submission #91170

#TimeUsernameProblemLanguageResultExecution timeMemory
91170davitmargMoney (IZhO17_money)C++17
0 / 100
2 ms476 KiB
/* DEATH-MATCH Davit-Marg */ #include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <string> #include <cstring> #include <map> #include <set> #include <queue> #include <deque> #include <stack> #include <iterator> #include <ctype.h> #include <stdlib.h> #include <fstream> #define mod 1000000007ll #define LL long long #define LD long double #define MP make_pair #define PB push_back using namespace std; int n,ans,a[1000006],l; set<int> s; stack<int> st; set<int>::iterator it; int main() { cin >> n; ans = 1; for (int i = 1; i <= n; i++) scanf("%d", a+i); s.insert(0); it = s.upper_bound(l); for (int i = 1; i <= n; i++) { if ((a[i] < a[i - 1]) || it != s.end() && (*it) < a[i] ) { l = a[i]; it = s.upper_bound(l); ans++; while (!st.empty()) { s.insert(st.top()); st.pop(); } } st.push(a[i]); } cout << ans << endl; return 0; } /* 6 1 3 5 2 4 6 */

Compilation message (stderr)

money.cpp: In function 'int main()':
money.cpp:40:42: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   if ((a[i] < a[i - 1]) || it != s.end() && (*it) < a[i] )
                            ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
money.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", a+i);
   ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...