제출 #36057

#제출 시각아이디문제언어결과실행 시간메모리
36057UncleGrandpa925Money (IZhO17_money)C++14
45 / 100
1500 ms52784 KiB
/*input
1
3
*/
#include <bits/stdc++.h>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define N 1000005
#define bit(x,y) ((x>>y)&1LL)
#define na(x) (#x) << ":" << x
ostream& operator << (ostream &os, vector<int>&x) {
	for (int i = 0; i < x.size(); i++) os << x[i] << sp;
	return os;
}
ostream& operator << (ostream &os, pair<int, int> x) {
	cout << x.fi << sp << x.se << sp;
	return os;
}
ostream& operator << (ostream &os, vector<pair<int, int> >&x) {
	for (int i = 0; i < x.size(); i++) os << x[i] << endl;
	return os;
}

int n;
int a[N];
set<int> st;
signed main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int t; scanf("%d", &a[i]);
	}
	int last = a[0], ans = 0;
	int mx = 1e9;
	st.insert(a[0]);
	int len = 1;
	for (int i = 1; i < n; i++) {
		if (a[i] < last) {
			ans++;
			auto it = st.upper_bound(a[i]);
			if (it == st.end()) mx = 1e9;
			else mx = *it;
		}
		else if (a[i] > mx) {
			ans++;
			auto it = st.upper_bound(a[i]);
			if (it == st.end()) mx = 1e9;
			else mx = *it;
		}
		last = a[i];
		st.insert(a[i]);
	}
	ans++;
	printf("%d\n", ans);
}

컴파일 시 표준 에러 (stderr) 메시지

money.cpp: In function 'std::ostream& operator<<(std::ostream&, std::vector<int>&)':
money.cpp:16:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < x.size(); i++) os << x[i] << sp;
                    ^
money.cpp: In function 'std::ostream& operator<<(std::ostream&, std::vector<std::pair<int, int> >&)':
money.cpp:24:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < x.size(); i++) os << x[i] << endl;
                    ^
money.cpp: In function 'int main()':
money.cpp:34:7: warning: unused variable 't' [-Wunused-variable]
   int t; scanf("%d", &a[i]);
       ^
money.cpp:39:6: warning: unused variable 'len' [-Wunused-variable]
  int len = 1;
      ^
money.cpp:32:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
money.cpp:34:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int t; 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...