题目很简单,一次就能 A,把代码拉过来测试一下发表文章~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
#include <iostream>
int main() {
int n;
while (std::cin >> n) {
if (!n)
return 0;
int currFloor = 0;
int sum = 0, aim;
while (n--) {
std::cin >> aim;
sum += ((currFloor > aim) ? (4) : (-6)) * (currFloor - aim) + 5;
currFloor = aim;
}
std::cout << sum << std::endl;
}
return 0;
}
|