답안 #758322

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
758322 2023-06-14T12:35:16 Z KN200711 스카이라인 (IZhO11_skyline) C++14
0 / 100
1 ms 212 KB
# include <bits/stdc++.h>
# define ll long long
# define fi first
# define se second
using namespace std;

int main() {
	int N;
	scanf("%d", &N);
	vector<int> arr(N);
	for(int i=0;i<N;i++) scanf("%d", &arr[i]);
	
	int ans = 0;
	for(int i=0;i<N;i++) {
		if(i == 0) {
			ans += 3 * arr[i];
		} else {
			if(arr[i-1] >= arr[i]) ans += 2 * arr[i];
			else ans += 2 * arr[i] + (arr[i] - arr[i - 1]);
		}
	}
	printf("%d\n", ans);
	return 0;
}

Compilation message

skyline.cpp: In function 'int main()':
skyline.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  scanf("%d", &N);
      |  ~~~~~^~~~~~~~~~
skyline.cpp:11:28: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  for(int i=0;i<N;i++) scanf("%d", &arr[i]);
      |                       ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -