# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
236159 | VEGAnn | Sažetak (COCI17_sazetak) | C++14 | 31 ms | 19832 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|---|---|---|---|
Fetching results... |