Submission #230723

# Submission time Handle Problem Language Result Execution time Memory
230723 2020-05-11T11:45:28 Z syy Baloni (COCI15_baloni) C++17
0 / 100
84 ms 14456 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int n, arr[1000005], mi[1000005], ans;
stack<int> s;

int main() {
	fastio; cin >> n;
	FOR(i, 1, n) cin >> arr[i];
	mi[n] = arr[n];
	DEC(i, n-1, 1) mi[i] = min(mi[i+1], arr[i]);
	FOR(i, 1, n) {
		if (!s.empty() and s.top() == arr[i]+1) s.top()--;
		else {
			s.push(arr[i]);
			ans++;
		}
		if (!s.empty() and s.top() == mi[i]) s.pop();
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Incorrect 5 ms 384 KB Output isn't correct
4 Incorrect 5 ms 512 KB Output isn't correct
5 Incorrect 84 ms 13324 KB Output isn't correct
6 Incorrect 84 ms 14456 KB Output isn't correct
7 Incorrect 62 ms 11864 KB Output isn't correct
8 Incorrect 62 ms 11768 KB Output isn't correct
9 Incorrect 78 ms 12664 KB Output isn't correct
10 Incorrect 75 ms 12920 KB Output isn't correct