Submission #31645

#TimeUsernameProblemLanguageResultExecution timeMemory
31645antran2202Baloni (COCI15_baloni)C++14
100 / 100
113 ms9988 KiB
#include <iostream> #include <set> #include <map> #include <queue> #include <cstdio> #include <algorithm> #include <stack> #include <vector> using namespace std; #define whole(x) x.begin(),x.end() #define sz(x) ((int)x.size()) #define sqr(x) ((x)*(x)) #define pb push_back #define mp make_pair #define ins insert #define maxn int (1e6 + 1) typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef vector<int> vi; //---------------------------------------------------------- int n, k, m; int shot[maxn] = {}, h[maxn] = {}; void Input () { cin >> n; cerr << n; for (int i = 1; i <= n; ++i) cin >> h[i]; } void Solve () { for (int i = n; i >= 1; --i) { ++shot[h[i]]; if (shot[h[i] - 1]) --shot[h[i] - 1]; } int res = 0; for (int i = 1; i < maxn; ++i) res += shot[i]; cout << res; } int main() { //freopen ("baloni.inp", "r", stdin); //freopen ("baloni.out", "w", stdout); ios_base::sync_with_stdio(false); cin.tie (NULL); cout.tie (NULL); Input (); Solve (); }
#Verdict Execution timeMemoryGrader output
Fetching results...