Submission #81161

# Submission time Handle Problem Language Result Execution time Memory
81161 2018-10-24T02:52:05 Z FutymyClone Baloni (COCI15_baloni) C++14
0 / 100
183 ms 32940 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 5;

int n, a[N], ptr[N], ans = 0;
bool used[N];
vector <int> pos[N];

int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]), pos[a[i]].push_back(i);
    for (int i = 1; i <= n; i++) {
        if (used[i]) continue;
        ans++;
        int pt = a[i];
        while (pt >= 1) {
            if (ptr[pt] >= pos[pt].size()) break;
            used[pos[pt][ptr[pt]++]] = true;
            pt--;
        }
    }

    printf("%d", ans);
    return 0;
}

Compilation message

baloni.cpp: In function 'int main()':
baloni.cpp:19:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (ptr[pt] >= pos[pt].size()) break;
                 ~~~~~~~~^~~~~~~~~~~~~~~~~
baloni.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
baloni.cpp:13:52: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 1; i <= n; i++) scanf("%d", &a[i]), pos[a[i]].push_back(i);
                                  ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 23800 KB Output isn't correct
2 Incorrect 24 ms 23924 KB Output isn't correct
3 Incorrect 23 ms 23980 KB Output isn't correct
4 Incorrect 25 ms 24020 KB Output isn't correct
5 Incorrect 163 ms 32348 KB Output isn't correct
6 Incorrect 173 ms 32756 KB Output isn't correct
7 Incorrect 131 ms 32756 KB Output isn't correct
8 Incorrect 152 ms 32756 KB Output isn't correct
9 Incorrect 183 ms 32940 KB Output isn't correct
10 Incorrect 146 ms 32940 KB Output isn't correct