Submission #35190

# Submission time Handle Problem Language Result Execution time Memory
35190 2017-11-18T16:11:56 Z ulna Money (IZhO17_money) C++11
0 / 100
0 ms 9828 KB
#include <bits/stdc++.h>
using namespace std;

// why am I so weak

int n;
int a[1000055];
int d[1000055];

inline void read(int &x) {
	x = 0;
	char ch = 0;

	while (ch < '0' || ch > '9') ch = getchar();

	while (ch >= '0' && ch <= '9') {
		x = x * 10 + (ch - '0');
		ch = getchar();
	}
}
int main() {
	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		read(a[i]);
	}

	int res = 1;

	for (int i = n - 1; i >= 0; i--) {
		d[a[i]]++;

		if (i != n - 1 && a[i + 1] != a[i]) {
			if (d[a[i + 1] - 1] - d[a[i]] > 0 || a[i + 1] < a[i]) {
				res++;
			}
		}
	}

	printf("%d\n", res);
	
	return 0;
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:22:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9828 KB Output is correct
2 Incorrect 0 ms 9828 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9828 KB Output is correct
2 Incorrect 0 ms 9828 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9828 KB Output is correct
2 Incorrect 0 ms 9828 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9828 KB Output is correct
2 Incorrect 0 ms 9828 KB Output isn't correct
3 Halted 0 ms 0 KB -