Submission #37186

# Submission time Handle Problem Language Result Execution time Memory
37186 2017-12-22T09:54:47 Z Ulugbek_Abdimanabov Money (IZhO17_money) C++14
0 / 100
0 ms 5928 KB
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;
const int MX = 1001000;

int n;
int a[MX];
set<int> ss;

int main() {
	freopen("money.in", "r", stdin);
	freopen("money.out", "w", stdout);
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d", a + i);
	int cnt = 0;
	int now = 0;
	while (now < n) {
		++cnt;
		auto it = ss.upper_bound(a[now]);
		int rb = 1e7;
		if (it != ss.end())
			rb = *it;
		int lb = a[now];
		while (now < n && a[now] >= lb && a[now] <= rb)
			ss.insert(a[now]), lb = a[now], ++now;
	}
	cout << cnt << "\n";
	return 0;
}


Compilation message

money.cpp: In function 'int main()':
money.cpp:30:33: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("money.in", "r", stdin);
                                 ^
money.cpp:31:35: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("money.out", "w", stdout);
                                   ^
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:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", a + i);
                     ^
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 5928 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 5928 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 5928 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 5928 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
2 Halted 0 ms 0 KB -