Submission

Status:

PPPPP

Subtask/Task Score:

100/100

Score: 100

User: Newton4566

Problemset: หินงอก

Language: cpp

Time: 0.005 second

Submitted On: 2026-10-06 21:23:05

#include <iostream>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    int len[10000];                  // large safety margin

    cin >> n;

    int totalWidth = 0, maxLen = 0;
    for (int i = 0; i < n; i++) {
        cin >> len[i];
        totalWidth += 2 * len[i];
        if (len[i] > maxLen) maxLen = len[i];
    }

    // build one row at a time, so no 2D canvas is needed
    for (int r = 0; r < maxLen; r++) {
        string line(totalWidth, ' ');
        int offset = 0;
        for (int k = 0; k < n; k++) {
            int L = len[k];
            if (r < L) {
                line[offset + r]         = '\\';
                line[offset + 2 * L - 1 - r] = '/';
            }
            offset += 2 * L;
        }
        int last = totalWidth - 1;
        while (last >= 0 && line[last] == ' ') last--;
        cout << line.substr(0, last + 1) << "\n";
    }
    return 0;
}