Submission #541752

# Submission time Handle Problem Language Result Execution time Memory
541752 2022-03-24T09:53:01 Z FazacasMihai Baloni (COCI15_baloni) C++17
0 / 100
1 ms 340 KB
#include <bits/stdc++.h>

using namespace std;

int v[105], v2[105];

int main()
{
    int n, k = 1, i, j, l;
    bool ok;
    cin>>n;
    for(i = 1; i <= n; i++)
    {
        cin>>v[i];
    }
    v2[k] = v[1];
    for(i = 2; i <= n; i++)
    {
        ok = 0;
        for(j = 1; j <= k; j++)
        {
            if(v[i] == v2[j] - 1)
            {
                v2[j]--;
                ok = 1;
            }
        }
        if(ok != 1)
        {
            k++;
            v2[k] = v[i];
        }
    }
    cout<<k;

    return 0;
}

Compilation message

baloni.cpp: In function 'int main()':
baloni.cpp:9:25: warning: unused variable 'l' [-Wunused-variable]
    9 |     int n, k = 1, i, j, l;
      |                         ^
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Runtime error 1 ms 340 KB Execution killed with signal 11
3 Runtime error 1 ms 340 KB Execution killed with signal 11
4 Runtime error 1 ms 340 KB Execution killed with signal 11
5 Runtime error 1 ms 340 KB Execution killed with signal 11
6 Runtime error 1 ms 340 KB Execution killed with signal 11
7 Runtime error 1 ms 340 KB Execution killed with signal 11
8 Runtime error 1 ms 340 KB Execution killed with signal 11
9 Runtime error 1 ms 340 KB Execution killed with signal 11
10 Runtime error 1 ms 340 KB Execution killed with signal 11