Submission #37561

# Submission time Handle Problem Language Result Execution time Memory
37561 2017-12-26T06:26:02 Z Abelyan Money (IZhO17_money) C++14
0 / 100
0 ms 10964 KB
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

const int N=1000006;
pair <int,int> a[N];
bool r[N];

int main(){
	ios_base::sync_with_stdio(false);
	freopen("money.in","r",stdin);
	freopen("money.out","w",stdout);
	int n;
	cin>>n;
	for (int i = 0; i < n; i++){
		int k;
		cin>>k;
		a[i].first=k;
		a[i].second=-i;
	}
	sort(a,a+n);
	int ans=1;
	r[-a[0].second+1]=true;
	for (int i = 1; i < n; i++){
		if (r[-a[i].second]){
			r[-a[i-1].second+1]=false;
			r[-a[i].second+1]=true;
		}
		else{
			if (-a[i].second < -a[i - 1].second){
				r[-a[i - 1].second + 1] = false;
				r[-a[i].second + 1] = true;
			}
			else{
				r[-a[i].second + 1] = true;
			}
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:13:31: 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:14:33: 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);
                                 ^
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 10964 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 10964 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 10964 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 10964 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
2 Halted 0 ms 0 KB -