"SWEA 1285 아름이의 돌 던지기"의 두 판 사이의 차이

 
(다른 사용자 한 명의 중간 판 하나는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개요==
==개요==
;SWEA 1285 아름이의 돌 던지기
{{SWEA|난이도=2}}
 
{{SWEA 헤더}}
{{SWEA 난이도 2-3}}
|}


==C++==
==C++==
<source lang='cpp'>
<syntaxhighlight lang='cpp'>
#include <iostream>
#include <iostream>
using namespace std;
using namespace std;
33번째 줄: 29번째 줄:
}
}
}
}
</source>
</syntaxhighlight>

2023년 8월 25일 (금) 02:11 기준 최신판

1 개요[ | ]

SWEA 1285 아름이의 돌 던지기

2 C++[ | ]

#include <iostream>
using namespace std;
int main() {
	int T, x;
	cin >> T;
	
	int N, n, distance, min_distance, min_count;
	for(x=1; x<=T; x++) {
		cin >> N;
		min_distance = 100001;
		for(n=0; n<N; n++) {
			cin >> distance;
			distance = abs(distance);
			if( distance < min_distance ) {
				min_distance = distance;
				min_count = 1;
				continue;
			}
			if( distance == min_distance ) {
				min_count++;
			}
		}
		cout << "#" << x << " " << min_distance << " " << min_count << endl;
	}
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}