Bomb Kirby Running
Cat Life - GT-K
1285번 아름이의 돌 던지기

2023. 4. 16. 21:34SWEA

Problem Solving - Level 2 - 아름이의 돌 던지기

https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=2&contestProbId=AV18-stqI8oCFAZN&categoryId=AV18-stqI8oCFAZN&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=2&pageSize=10&pageIndex=3 

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
    int T;
    cin>>T;
    
    for(int i=1;i<=T;i++)
    {
        int num,distance,count=0,min=100000;
        cin>>num;
        for(int j=0;j<num;j++)
        {
            cin>>distance;
            distance=abs(distance);
            if(distance<min)
            {
                min=distance;
                count=1;
            }
            
            else if(distance==min)
            {
                count++;
            }
        }
        cout<<"#"<<i<<" "<<min<<" "<<count<<endl;
    }
    return 0;
}

 

'SWEA' 카테고리의 다른 글

1928번 Base64 Decoder  (0) 2023.04.16
1288번 새로운 불면증 치료법  (0) 2023.04.16
1284번 수도 요금 경쟁  (0) 2023.04.16
1204번 최빈수 구하기  (0) 2023.04.16
2072번 홀수만 더하기  (0) 2023.03.23