목록알고리즘 (53)
눈송이의 개발생활
문제 https://www.acmicpc.net/problem/11047 코드 #include #include #include using namespace std; vector v; int main(){ cin.tie(0), cout.tie(0); ios_base::sync_with_stdio(0); int n, k, x; int count = 0; cin >> n >> k; for(int i=0; i> x ; v.push_back(x); } sort(v.begin(), v.end(), greater()); for(int i=0; i= 0){ k = k-v[i]; count++; } } cout
문제 https://www.acmicpc.net/problem/11568 코드 #include #include using namespace std; int dp[1001]; int arr[1001]; int main(){ cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int n; cin >> n; for(int i=0; i> arr[i]; dp[i]=1; } //LIS 사용 int result = 1; for(int i=0; i
문제 https://www.acmicpc.net/problem/11048 코드 #include #include using namespace std; int dp[1001][1001]; int arr[1001][1001]; int main(){ cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int n, m; cin >> n >> m; for(int i=1; i arr[i][j]; } } for(int i=1; i
문제 https://www.acmicpc.net/problem/11726 코드 #include #include using namespace std; int dp[1001]; int main(){ cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int n; cin >> n; dp[1]=1; dp[2]=2; for(int i=3; i
문제 https://www.acmicpc.net/problem/9095 코드 #include #include using namespace std; int dp[10001]; int main(){ cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int tc, n; dp[1]= 1; dp[2]=2; dp[3]=4; cin >> tc; for(int i=0; i> n; for (int i=4; i
문제 https://www.acmicpc.net/problem/2346 코드 #include #include using namespace std; typedef pair pairs; deque dq; int main(void){ cin.tie(0);cout.tie(0); ios_base::sync_with_stdio(false); int n; cin >> n; for(int i=0; i> x; dq.push_back(make_pair(i+1, x)); } while(!dq.empty()){ pairs poped = dq.front(); cout
문제 https://www.acmicpc.net/problem/3078 코드 방법#1 #include #include #include using namespace std; int main(void){ cin.tie(0);cout.tie(0); ios_base::sync_with_stdio(false); int n, k; long long sumNum=0; int outNum; string name; queue q; int arr[21] = {}; //큐 내에 있는 이름 길이 배열 cin >> n >> k; //큐 초기화 for(int i=0; i name; int length1 = name.length(); sumNum += arr[length1]; outNum = q.front(); q.pop(); q..
문제 https://www.acmicpc.net/problem/10799 코드 #include #include #include using namespace std; int main(void){ cin.tie(0);cout.tie(0); ios_base::sync_with_stdio(false); stack s; string str; int sum=0; cin >> str; for(int i =0; i< str.length(); i++){ if(str.at(i) == '(') { s.push(str.at(i)); } else{ if(str.at(i-1) == '('){ s.pop(); sum += s.size(); } else{ s.pop(); sum +=1; } } } cout