Submission #165020

# Submission time Handle Problem Language Result Execution time Memory
165020 2019-11-24T16:51:28 Z Rouge_Hugo Baloni (COCI15_baloni) C++14
100 / 100
442 ms 7516 KB
    #include <bits/stdc++.h>
    #define ll long long
    #define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    using namespace std;
    int n;
    int a[1000009],b[1000009];
    int main()
    {
        cin>>n;
        for(int i=0;i<n;i++)cin>>a[i];
        for(int i=n-1;i>-1;i--)
        {
            if (b[a[i]-1]>0)b[a[i]-1]--;
            b[a[i]]++;
        }
        ll sum=0;
        for(int i=1;i<1000003;i++)sum+=b[i];
        cout<<sum;
    }
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 339 ms 7032 KB Output is correct
6 Correct 340 ms 7516 KB Output is correct
7 Correct 274 ms 6008 KB Output is correct
8 Correct 442 ms 6008 KB Output is correct
9 Correct 306 ms 6532 KB Output is correct
10 Correct 302 ms 6520 KB Output is correct