답안 #335519

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
335519 2020-12-13T00:37:41 Z luciocf Money (IZhO17_money) C++14
0 / 100
1 ms 492 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e6+10;

int a[maxn];

int main(void)
{
	int n;
	scanf("%d", &n);

	multiset<int> st;

	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		st.insert(a[i]);
	}

	int ans = 0;

	for (int r = n; r >= 1; r--)
	{
		++ans;

		int l = r;
		auto it = st.upper_bound(a[r]);
		--it;

		while (l > 1)
		{
			if (a[l-1] != *prev(it)) break;
			it--, l--;
		}


		for (int i = r; i >= l; i--)
			st.erase(st.find(a[i]));

		r = l;
	}

	printf("%d\n", ans);
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
money.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |   scanf("%d", &a[i]);
      |   ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 492 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 492 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 492 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 492 KB Output isn't correct
5 Halted 0 ms 0 KB -