제출 #91172

#제출 시각아이디문제언어결과실행 시간메모리
91172davitmargMoney (IZhO17_money)C++17
45 / 100
1554 ms51692 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); for (int i = 1; i <= n; i++) { it = s.upper_bound(l); if ((a[i] < a[i - 1]) || it != s.end() && (*it) < a[i] ) { l = a[i]; 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 */

컴파일 시 표준 에러 (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...