Algorithm/goorm

goorm 최단거리, 좀비런, 재정 위기

마띠(쥔장) 2020. 9. 1. 23:58

최단거리

# -*- coding: utf-8 -*-
# UTF-8 encoding when using korean
a = int(input())
ary = []
ary = input().split(' ')
d = int(ary[1]) - int(ary[0])
for i in range(a-1):
	if((int(ary[i+1]) - int(ary[i]))<d):
		d = int(ary[i+1]) - int(ary[i])
print(d)

 

좀비런

# -*- coding: utf-8 -*-
# UTF-8 encoding when using korean
n = int(input())
ary = []
ary = input().split(' ')
m = int(ary[0])
for i in range(n):
	if(int(ary[i]) > int(m)):
		m = ary[i]
print(m)

 

재정 위기

#include <iostream>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if((b>=a&&c<=a)||(b<=a&&c>=a))
		cout<<a;
	else if((a>=b&&c<=b)||(a<=b&&c>=b))
		cout<<b;
	else
		cout<<c;
	return 0;
}
728x90