diff --git "a/src/dayoung/week17/\353\213\244\353\213\250\352\263\204\354\271\253\354\206\224\355\214\220\353\247\244.swift" "b/src/dayoung/week17/\353\213\244\353\213\250\352\263\204\354\271\253\354\206\224\355\214\220\353\247\244.swift" new file mode 100644 index 0000000..ff67f06 --- /dev/null +++ "b/src/dayoung/week17/\353\213\244\353\213\250\352\263\204\354\271\253\354\206\224\355\214\220\353\247\244.swift" @@ -0,0 +1,44 @@ +// +// main.swift +// week17 +// +// Created by 장다영 on 2021/07/18. +// + +import Foundation + +func solution(_ enroll:[String], _ referral:[String], _ seller:[String], _ amount:[Int]) -> [Int] { + + var net = Dictionary() + var profits = Dictionary() + + profits["-"] = 0 + + func money(_ profit: Int) -> Int { + return Int(Double(profit) * 0.1) + } + + func pass(_ name: String, earn: Int) { + if earn == 0 { + return + } + + profits[name]! += earn + if name != "-" { + profits[name]! -= money(earn) + pass(net[name]!, earn: money(earn)) + } + } + + for i in 0.. [String] { + var nickName: [String : String] = [:] + var result: [String] = [] + + for i in record { + let arr = i.components(separatedBy: " ") + + if arr.count > 2 { + nickName[arr[1]] = arr[2] + } + } + + for i in record { + let arr = i.components(separatedBy: " ") + let name = nickName[arr[1]]! + + if arr[0] == "Enter" { + result.append("\(name)님이 들어왔습니다.") + } + else if arr[0] == "Leave" { + result.append("\(name)님이 나갔습니다.") + } + } + return result +} diff --git a/src/sangmin/week17/BOJ5557/.vscode/settings.json b/src/sangmin/week17/BOJ5557/.vscode/settings.json new file mode 100644 index 0000000..d7d9270 --- /dev/null +++ b/src/sangmin/week17/BOJ5557/.vscode/settings.json @@ -0,0 +1,65 @@ +{ + "files.associations": { + "__bit_reference": "cpp", + "__config": "cpp", + "__debug": "cpp", + "__errc": "cpp", + "__functional_base": "cpp", + "__hash_table": "cpp", + "__locale": "cpp", + "__mutex_base": "cpp", + "__node_handle": "cpp", + "__nullptr": "cpp", + "__split_buffer": "cpp", + "__string": "cpp", + "__threading_support": "cpp", + "__tuple": "cpp", + "algorithm": "cpp", + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "bitset": "cpp", + "cctype": "cpp", + "chrono": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "complex": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "exception": "cpp", + "functional": "cpp", + "initializer_list": "cpp", + "ios": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "iterator": "cpp", + "limits": "cpp", + "locale": "cpp", + "memory": "cpp", + "mutex": "cpp", + "new": "cpp", + "optional": "cpp", + "ostream": "cpp", + "ratio": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "string": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "typeinfo": "cpp", + "unordered_map": "cpp", + "utility": "cpp", + "vector": "cpp" + } +} \ No newline at end of file diff --git a/src/sangmin/week17/BOJ5557/main b/src/sangmin/week17/BOJ5557/main new file mode 100755 index 0000000..081827f Binary files /dev/null and b/src/sangmin/week17/BOJ5557/main differ diff --git a/src/sangmin/week17/BOJ5557/main.cpp b/src/sangmin/week17/BOJ5557/main.cpp new file mode 100644 index 0000000..afa6189 --- /dev/null +++ b/src/sangmin/week17/BOJ5557/main.cpp @@ -0,0 +1,29 @@ +#include +#define MAX 110 +using namespace std; + +int N; +int ary[MAX]; +long long dp[MAX][30]; + +int main(){ + cin >> N; + for(int i = 1; i<=N; i++) + cin >> ary[i]; + ary[0] = 0; + dp[0][0] = 0; + + dp[1][ary[1]] = 1; + for(int i = 2; i<=N; i++){ + for(int j = 0; j<=20; j++){ + if(dp[i-1][j] >= 0){ + if(j - ary[i] >= 0) dp[i][j-ary[i]] += dp[i-1][j]; + if(j + ary[i] <= 20) dp[i][j+ary[i]] += dp[i-1][j]; + } + } + } + + cout << dp[N-1][ary[N]] << endl; + + return 0; +} \ No newline at end of file diff --git a/src/sangmin/week17/BOJ5557/main.dSYM/Contents/Info.plist b/src/sangmin/week17/BOJ5557/main.dSYM/Contents/Info.plist new file mode 100644 index 0000000..fe7fecd --- /dev/null +++ b/src/sangmin/week17/BOJ5557/main.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.main + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/src/sangmin/week17/BOJ5557/main.dSYM/Contents/Resources/DWARF/main b/src/sangmin/week17/BOJ5557/main.dSYM/Contents/Resources/DWARF/main new file mode 100644 index 0000000..dc6cb80 Binary files /dev/null and b/src/sangmin/week17/BOJ5557/main.dSYM/Contents/Resources/DWARF/main differ