Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- Flow
- KMP
- MST
- DFS
- SlidingWindow
- backtracking
- Sweeping
- topologicalsort
- Implementation
- LCA
- 2-sat
- DP
- ArticulationPoint
- ShortestPath
- Floyd
- FenwickTree
- LIS
- BFS
- Tree
- greedy
- Bridge
- IndexedTree
- TwoPointers
- Bellman-Ford
- Math
- scc
- BinarySearch
- mergesorttree
- Union-Find
- Dijkstra
Archives
- Today
- Total
정리충의 정리노트
[백준] 1222: 홍준 프로그래밍 대회 본문
0. 문제 주소
https://www.acmicpc.net/problem/1222
1222번: 홍준 프로그래밍 대회
문제 홍준이는 프로그래밍 대회를 개최했다. 이 대회는 사람들이 팀을 이루어서 참가해야 하며, 팀원의 수는 홍준이가 정해준다. 팀원이 홍준이가 정한 값보다 부족하다면, 그 팀은 대회에 참여
www.acmicpc.net
1. 풀이
주어지는 수들의 범위가 작은 경우 그 수들을 인덱스로 이용하는 방법을 까먹지 말자
2. 풀이 코드
* 유의할 점
#include <bits/stdc++.h>
#define ll long long
const int MAX = 2000005;
using namespace std;
int arr[MAX];
int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int N;
scanf("%d", &N);
for (int i=0;i<N;i++){
int temp;
scanf("%d", &temp);
arr[temp]++;
}
ll ans = 0;
for (int i=1;i<MAX;i++){
ll curr_cnt = 0;
for (int j=1;i*j<=MAX;j++){
curr_cnt += arr[i*j];
}
if (curr_cnt < 2) continue;
ans = max(ans, (ll)i * curr_cnt);
}
printf("%lld\n", ans);
return 0;
}
Comments