Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/dayoung/week17/다단계칫솔판매.swift
Original file line number Diff line number Diff line change
@@ -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<String, String>()
var profits = Dictionary<String ,Int>()

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..<enroll.count {
net[enroll[i]] = referral[i]
profits[enroll[i]] = 0
}

for i in 0..<seller.count {
pass(net[seller[i]]!, earn: money(amount[i] * 100))
profits[seller[i]]! += amount[i] * 90
}

return enroll.map{profits[$0]!}
}
34 changes: 34 additions & 0 deletions src/dayoung/week17/오픈채팅방.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// 오픈채팅방.swift
// week17
//
// Created by 장다영 on 2021/07/18.
//

import Foundation

func solution(_ record:[String]) -> [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
}
65 changes: 65 additions & 0 deletions src/sangmin/week17/BOJ5557/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
Binary file added src/sangmin/week17/BOJ5557/main
Binary file not shown.
29 changes: 29 additions & 0 deletions src/sangmin/week17/BOJ5557/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <iostream>
#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;
}
20 changes: 20 additions & 0 deletions src/sangmin/week17/BOJ5557/main.dSYM/Contents/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.xcode.dsym.main</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>dSYM</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
Binary file not shown.