목록Algorithm/C++ (148)
cgy12306
// https://www.acmicpc.net/problem/1920 // 수 찾기 #include #include #include using namespace std; long long N, M, a; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); vector v1; vector::iterator it; cin >> N; for (int i = 0; i > a; v1.push_back(a); } cin >> M; for (int i = 0; i > a; it = find(v1.begin(), v1.end(), a); if (it != v1.end()) cout
// https://www.acmicpc.net/problem/1181 // 단어 정렬 #include #include #include #include using namespace std; bool size_compare(string a, string b) { if (a.size() == b.size()) return a > N; for (int i = 0; i > s; v.push_back(s); } sort(v.begin(),..
// https://www.acmicpc.net/problem/1929 // 소수 구하기 #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int m, n; bool arr[1000001]{ 0, }; cin >> m >> n; arr[0] = 1; arr[1] = 1; for (int i = 2; i
// https://www.acmicpc.net/problem/11057 // 오르막 수 #include using namespace std; long long dp[12]; int main() { int n; cin >> n; for (int i = 1; i
// https://www.acmicpc.net/problem/9465 // 스티커 #include #include using namespace std; int arr[2][100001], dp[2][100001]; void print(int arr[2][100001], int n) { for (int i = 0; i x; arr[i][j] = x; } } if (n == 1) { if (arr[0][1] >= arr[1][1]) cout
// https://www.acmicpc.net/problem/11055 // 가장 큰 증가하는 부분 수열 #include #include using namespace std; int arr[1001] = { 0, }, dp[1001] = { 0, }; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; for (int i = 0; i > arr[i]; dp[i] = arr[i]; } for (int i = 1; i arr[j] && dp[i] < dp[j] + arr[..
// https://www.acmicpc.net/problem/11722 // 가장 긴 감소하는 부분 수열 #include #include using namespace std; int arr[1001], dp[1001]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; for (int i = 0; i > arr[i]; } fill(dp, dp + 1000, 1); for (int i = 1; i < n; i++) { for (int j = 0; j < i; j++) { if (arr[i] < arr[j] && dp[i]
// https://www.acmicpc.net/problem/11053 // 가장 긴 증가하는 부분 수열 #include #include using namespace std; int arr[1001] = { 0, }, dp[1001] = { 0, }; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; for (int i = 0; i > arr[i]; } fill(dp, dp + 1000, 1); for (int i = 1; i arr[j] && dp[i]