# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
40986 | 2018-02-10T19:29:02 Z | IvanC | Sažetak (COCI17_sazetak) | C++14 | 74 ms | 40032 KB |
#include <bits/stdc++.h> using namespace std; const int MAXN = 5*1e6 + 10; int pai[MAXN],peso[MAXN],N,M; int find(int x){ if(x == pai[x]) return x; return pai[x] = find(pai[x]); } void join(int x,int y){ x = find(x); y = find(y); if(x == y) return; if(peso[x] < peso[y]) pai[x] = y; else if(peso[x] > peso[y]) pai[y] = x; else{ pai[x] = y; peso[y]++; } } int main(){ scanf("%d %d",&N,&M); for(int i = 1;i<=N+1;i++){ pai[i] = i; } for(int m = 1;m<=M;m++){ int k; scanf("%d",&k); for(int i = 1;i<=N;i+=k){ int nxt = min(N+1,i+k); join(i,nxt); } } int ans = 0; for(int i = 1;i<=N;i++) if(find(i) == find(i+1)) ans++; printf("%d\n",ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 42 ms | 16652 KB | Output is correct |
4 | Correct | 74 ms | 19364 KB | Output is correct |
5 | Runtime error | 45 ms | 39800 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
6 | Runtime error | 43 ms | 39972 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
7 | Runtime error | 40 ms | 39972 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
8 | Runtime error | 39 ms | 40016 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
9 | Runtime error | 44 ms | 40032 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
10 | Runtime error | 40 ms | 40032 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |