[SWEA] 7333 한솔이의 택배 아르바이트

Time Lapse :1hour 20min 23sec

7333.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(int argc, char** argv)
{
int test_case,N,num,multi,answer;
int T;
vector<int> Boxes;
Boxes.reserve(100);
scanf("%d",&T);
for(test_case = 1; test_case <= T; ++test_case)
{
scanf("%d",&N);
Boxes.clear();
answer = 0;
for(int i=0;i<N;i++){
scanf("%d",&num);
Boxes.push_back(num);
}
sort(Boxes.begin(),Boxes.end());
auto it_front = Boxes.begin();
auto it_end = Boxes.end()-1;
while(it_end>=it_front){
if(it_end==it_front){
if(*it_end>=50)
++answer;
break;
}
multi = 1;
while(((*it_end)*multi)<50){
++multi; ++it_front;
if(it_front>it_end){
--answer;
break;
}
}
--it_end;
++answer;
}
printf("#%d %d\n",test_case,answer);
}
return 0;//정상종료시 반드시 0을 리턴해야합니다.
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/08/04/PS/SWEA/7333/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.