제출 #335521

#제출 시각아이디문제언어결과실행 시간메모리
335521luciocfMoney (IZhO17_money)C++14
45 / 100
1596 ms58220 KiB
#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;

		while (l > 1 && a[l-1] == a[l]) l--;

		auto it = st.lower_bound(a[r]);

		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);
}

컴파일 시 표준 에러 (stderr) 메시지

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]);
      |   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...