diff --git a/usaco/base.cpp b/usaco/base.cpp new file mode 100644 index 0000000..727ea22 --- /dev/null +++ b/usaco/base.cpp @@ -0,0 +1,22 @@ +/* +ID: philipp17 +PROG: +LANG: C++ +*/ +/* LANG can be C++11 or C++14 for those more recent releases */ +#include +#include +#include + +using namespace std; + +int main() { + ofstream fout (".out"); + ifstream fin (".in"); + + string a, b; + + fin >> a >> b; + + return 0; +} \ No newline at end of file diff --git a/usaco/ch1/gift1.cpp b/usaco/ch1/gift1.cpp new file mode 100644 index 0000000..4994c6e --- /dev/null +++ b/usaco/ch1/gift1.cpp @@ -0,0 +1,70 @@ +/* +ID: philipp17 +PROG: gift1 +LANG: C++ +*/ +/* LANG can be C++11 or C++14 for those more recent releases */ +#include +#include +#include +#include +#include + +using namespace std; + + +int main() { + ofstream fout ("gift1.out"); + ifstream fin ("gift1.in"); + + int np; + fin >> np; + + map names_to_index; + map index_to_name; + + vector bank(np, 0); + vector spendings(np, 0); + + for(int i = 0; i < np; ++i){ + string s; + fin >> s; + + names_to_index[s] = i; + index_to_name[i] = s; + } + + for(int i = 0; i < np; ++i){ + string name; + int money, ng; + + fin >> name >> money >> ng; + + if(ng == 0){ + continue; + } + + vector receivers(ng); + for(int j = 0; j < ng; ++i){ + fin >> receivers[j]; + } + + if(money == 0){ + continue; + } + + int money_per_person = money / ng; + + for(const string &receiver : receivers){ + bank[names_to_index[receiver]] += money_per_person; + spendings[names_to_index[receiver]] -= money_per_person; + } + } + + // Printing the output + for(int i = 0; i < np; ++i){ + fout << index_to_name[i] << bank[i] - spendings[i] << endl; + } + + return 0; +} \ No newline at end of file