Submission #377048

# Submission time Handle Problem Language Result Execution time Memory
377048 2021-03-12T21:03:03 Z ijxjdjd Money (IZhO17_money) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
#define FR(i, N) for (int i = 0; i < int(N); i++)
#define all(x) begin(x), end(x)

using namespace std;

using ll = long long;

int main() {
	cin.tie(0);
	cin.sync_with_stdio(0);
	int N;
	multiset<int> left;
	cin >> N;
	vector<int> arr(N);
	FR(i, N) {
	    cin >> arr[i];
        left.insert(arr[i]);
    }
    int lst = arr[N-1];
    left.erase(left.find(arr[N-1]));
    int ans = 1;
    for (int i = N-2; i >= 0; i--) {
        auto it = left.upper_bound(lst);
        if (it != left.begin() && *(prev(it)) == arr[i]) {
        }
        else {
            lst = arr[i];
            ans++;
        }
        left.erase(left.find(arr[i]));
    }
    cout << ans << '\n';
	return 0;
}
# Verdict Execution time Memory 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 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 364 KB Output isn't correct
5 Halted 0 ms 0 KB -