Submission #173073

#TimeUsernameProblemLanguageResultExecution timeMemory
173073touristMoney (IZhO17_money)C++14
0 / 100
2 ms380 KiB
#include <iostream>
#include <set>
#include <vector>

using namespace std;

#define ll long long
#define sz(x) (int)x.size()
#define pii pair < int, int >
#define endl "\n"
#define METH ios::sync_with_stdio(0); cin.tie(0);
#define BEGIN cout << "BEGIN" << endl;
#define END cout << "END" << endl;

const int mod = 1e9 + 7;															/// ANOTHER HASH MOD: 228228227
const int prime = 29;																	/// ANOTHER HASH PRIME: 997
const int INF = ((long long) 0xCAFEBABE - 1e9 - 4e8);

int n;
set < int > nw;
vector < int > v;

inline void read() {
	v.push_back(0);
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		int a; scanf("%d", &a);
		v.push_back(a);
	}
}

inline void solve() {
	int ans = 1;
	nw.insert(-INF);
	nw.insert(INF);
	for (int i = 1; i <= n; i++) {
		if (v[i] > *(nw.upper_bound(v[i - 1]))) {
			ans++;
		} else if (v[i - 1] > v[i]) {
			ans++;
		}
		nw.insert(v[i]);
	}

	cout << ans << endl;
}

int main() {
	int t = 1;
	while (t--) {
		read();
		solve();
	}
}

Compilation message (stderr)

money.cpp: In function 'void read()':
money.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
money.cpp:27:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int a; scanf("%d", &a);
          ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...