Submission #37185

# Submission time Handle Problem Language Result Execution time Memory
37185 2017-12-22T09:53:42 Z Ulugbek_Abdimanabov Money (IZhO17_money) C++14
0 / 100
0 ms 5924 KB
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <map>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <bitset>
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
#define y1 sda
using namespace std;    
const int N = int(1e6) + 10, mod = int(1e9)  + 7;

int n, a[N]; 
set <int> st;

set <int> :: iterator it;

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 i = 0, j = 0,mx ;
	int ans = 0;
	while(i < n){
		j = i;
		it = st.upper_bound(a[i]);
		if(it == st.end()){
			mx = mod;
		}
		else mx = *it;
		st.insert(a[i]);
		while(j + 1 < n && a[j + 1] >= a[j] && a[j + 1] <= mx){
			j++;
			st.insert(a[j]);
		}
		i = j + 1;
		ans++;
	}
	printf("%d\n", ans);


return 0;
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:35:32: 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:36:34: 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:37:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
money.cpp:39:20: 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 5924 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 5924 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 5924 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 5924 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
2 Halted 0 ms 0 KB -