목록전체 글 (253)
bdfgdfg
#include #include using namespace std; int solution(vector absolutes, vector signs) { int answer = 0; int len = absolutes.size(); for(int i = 0; i < len; ++i) { if(signs[i]) answer += absolutes[i]; else answer += (absolutes[i] * -1); } return answer; }
#include #include using namespace std; int solution(int left, int right) { int answer = 0; vector count; count.resize(1001); for(int i = left; i
#include #include #include #include using namespace std; int solution(vector d, int budget) { int answer = 0; // 최대한 많은 부서에 전달. sort(d.begin(),d.end()); for(int i = 0; i < d.size(); ++i) { budget -= d[i]; if(budget < 0) break; ++answer; } return answer; }
#include #include #include using namespace std; int solution(int n) { int answer = 0; stack a; while(n >= 1) { a.push(n % 3); n /= 3; } int len = a.size(); int digit = 1; for(int i = 0; i < len; ++i) { answer += a.top() * digit; a.pop(); digit *= 3; } return answer; }