Submission #236159

# Submission time Handle Problem Language Result Execution time Memory
236159 2020-05-31T10:25:01 Z VEGAnn Sažetak (COCI17_sazetak) C++14
64 / 160
31 ms 19832 KB
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define a3 array<int, 3>
using namespace std;
const int oo = 2e9;
const int M = 20;
#ifdef _LOCAL
const int N = int(1.5e8);
#else
const int N = int(5e6) + 10;
#endif
bitset<N> mrk;
int nt[N], n, m, a[M], ans = 0, extend[M];

bool ok(int lf, int rt, int x){
    for (int i = 0; i < m; i++){
        int rit = rt;

        if (rt == n)
            rit = extend[i];

        int bd = (x / a[i]) * a[i];

        if (lf > bd && rit >= bd + a[i])
            return 1;
    }
    return 0;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

#ifdef _LOCAL
    freopen("in.txt","r",stdin);
#endif // _LOCAL

    cin >> n >> m;

    mrk[n] = 1;

    for (int i = 0; i < m; i++){
        cin >> a[i];

        for (int j = a[i]; j <= n; j += a[i])
            mrk[j] = 1;

        if (n % a[i] > 0)
            extend[i] = n + (a[i] - n % a[i]);
        else extend[i] = n;
    }

    for (int i = n; i > 1; i--) {
        nt[i] = nt[i + 1];

        if (mrk[i] && mrk[i - 1]){
            ans++;
            nt[i]++;
        } else nt[i] = 0;
    }

//    int lst = 0;
//
//    for (int i = 1; i <= n; i++)
//        if (nt[i] > 0){
//            lst++;
//        } else {
//            int lf = i - lst;
//            int rt = i + nt[i + 1];
//
//            if (ok(lf, rt, i)){
//                ans++;
//                lst++;
//            } else lst = 0;
//        }

    cout << ans;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 19 ms 17152 KB Output is correct
4 Correct 31 ms 19832 KB Output is correct
5 Runtime error 6 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 6 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 6 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 6 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 6 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 6 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)