Submission

Status:
[PPPPPPPPP]

Score: 100

User: Nathlol2

Problemset: ภูเขา

Language: cpp

Time: 0.001 second

Submitted On: 2024-09-29 13:58:22

#include <stdio.h>

int mx(int *p, int n){
	int mx = -100;
	for(int i = 0;i<n;i++){
		if(mx<p[i]){
			mx = p[i];
		}
	}
	return mx;
}

int main(){
	int n;
	scanf("%d", &n);
	int a[n];
	for(int i = 0;i<n;i++){
		scanf("%d", &a[i]);
	}
	int sum[n + 1];
	sum[0] = 0;
	for(int i = 1;i<=n;i++){
		sum[i] = (a[i - 1] * 2) + sum[i - 1];
	}
	//sum n + 1 == a[n]
	int max = mx(a, n);
	char pupa[max][sum[n]];
	for(int i = 0;i<max;i++){
		for(int z = 0;z<sum[n];z++){
			pupa[i][z] = '.';
		}
	}
	int c = 0;
	int high = max - 1;
	for(int i = 0;i<n;i++){
		while(c < sum[i + 1]){
			if(i == 0){
				if(c <= a[i] - 1){
					pupa[high][c] = '/';
					if(c != a[i] - 1){
						high = high - 1;
					}
				}else{
					pupa[high][c] = '\\';
					if(c != sum[i + 1] - 1){
						high = high + 1;
					}
				}
			}else{
				if(c <= sum[i] + a[i] - 1){
					pupa[high][c] = '/';
					if(c != sum[i] + a[i] - 1){
						high = high - 1;
					}
				}else{
					pupa[high][c] = '\\';
					if(c != sum[i + 1] - 1){
						high = high + 1;
					}
				}
			}
			c = c + 1;
		}
	}
	for(int i = 0;i<max;i++){
		for(int q = 0;q<sum[n];q++){
			printf("%c", pupa[i][q]);
		}
		printf("\n");
	}
}