답안 #1054268

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1054268 2024-08-12T08:14:54 Z unnick Skyscraper (JOI16_skyscraper) C++14
5 / 100
2000 ms 604 KB
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, l, sum = 0;
    cin >> n >> l;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> p(n);
    for (int i = 0; i < n; i++) p[i] = i;
    vector<int> ct(n);
    for (int i = 0; i < n; i++) ct[i] = true;
    while (true) {
        int s = 0;
        for (int i = 0; i < n-1; i++) {
            s += abs(a[p[i]] - a[p[i+1]]);
        }
        if (s <= l) sum++;
        int ptr = n-1;
        while (ptr >= 0) {
            ct[p[ptr]] = false;
            p[ptr]++;
            while (p[ptr] < n && ct[p[ptr]]) {
                p[ptr]++;
            }
            if (p[ptr] < n) break;
            ptr--;
        }
        if (ptr < 0) break;
        ct[p[ptr]] = true;
        for (int i = 0; i < n; i++) {
            if (!ct[i]) {
                ct[i] = true;
                p[++ptr] = i;
            }
        }
    }
    cout << sum << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 392 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2067 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 392 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Execution timed out 2067 ms 348 KB Time limit exceeded
12 Halted 0 ms 0 KB -