답안 #386237

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
386237 2021-04-06T07:52:59 Z patrikpavic2 Money (IZhO17_money) C++17
0 / 100
2 ms 380 KB
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <algorithm>

#define X first
#define Y second
#define PB push_back

using namespace std;

const int N = 1e6 + 500;

int A[N], n, prv[N], nxt[N], sol;
multiset < int > S;

int main(){
	scanf("%d", &n);
	for(int i = 0;i < n;i++){
		scanf("%d", A + i);
		S.insert(A[i]);
	}
	for(int i = n - 1;i >= 0;i--){
		S.erase(S.lower_bound(A[i]));
		int rub1 = 1, rub2 = 0;
		while(i > 0 && A[i] >= *S.begin() && ((!rub2 && (A[i - 1] == *(--S.upper_bound(A[i])) || A[i - 1] == *(--S.lower_bound(A[i])))) || A[i - 1] == A[i])){
			if(A[i - 1] != *(--S.upper_bound(A[i]))){
				if(rub1) rub1 = 0;
				else rub2 = 1;
			}
			i--; S.erase(S.lower_bound(A[i]));
		}
		sol++;
	}
	printf("%d\n", sol);
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
money.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |   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 Correct 1 ms 380 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Incorrect 1 ms 364 KB Output isn't correct
13 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 Correct 1 ms 380 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Incorrect 1 ms 364 KB Output isn't correct
13 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 Correct 1 ms 380 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Incorrect 1 ms 364 KB Output isn't correct
13 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 Correct 1 ms 380 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Incorrect 1 ms 364 KB Output isn't correct
13 Halted 0 ms 0 KB -