Submission #31729

# Submission time Handle Problem Language Result Execution time Memory
31729 2017-09-03T01:07:13 Z simotion Baloni (COCI15_baloni) C++14
100 / 100
116 ms 9828 KB
#include <bits/stdc++.h>
using namespace std;
int inp[1000002],n,h[1000002],sum;
int main() {
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&inp[i]);
    sum++,h[inp[n-1]]++;
    for(int i=n-2;i>=0;i--) {
        if(h[inp[i]-1]) h[inp[i]-1]--;
        else sum++;
        h[inp[i]]++;
    }
    printf("%d",sum);
}

Compilation message

baloni.cpp: In function 'int main()':
baloni.cpp:5:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
baloni.cpp:6:45: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<n;i++) scanf("%d",&inp[i]);
                                             ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9828 KB Output is correct
2 Correct 0 ms 9828 KB Output is correct
3 Correct 0 ms 9828 KB Output is correct
4 Correct 0 ms 9828 KB Output is correct
5 Correct 96 ms 9828 KB Output is correct
6 Correct 116 ms 9828 KB Output is correct
7 Correct 93 ms 9828 KB Output is correct
8 Correct 79 ms 9828 KB Output is correct
9 Correct 116 ms 9828 KB Output is correct
10 Correct 86 ms 9828 KB Output is correct