Submission #1094551

# Submission time Handle Problem Language Result Execution time Memory
1094551 2024-09-29T22:36:12 Z Izzy Just Long Neckties (JOI20_ho_t1) C++14
0 / 100
0 ms 344 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int n;

int main() {
    cin >> n;
    vector<int> ties(n + 1);
    vector<int> current(n);
    for (int i = 0; i <= n; i++) {
        cin >> ties[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> current[i];
    }
    sort(ties.begin(), ties.end());
    sort(current.begin(), current.end());
    
    vector<int> start = {0};
    vector<int> shifted = {0};

    int temp1 = 0;
    int temp2 = 0;
    for (int i = 0; i < n; i++) {
        temp1 = max(temp1, ties[i] - current[i]);
        start.push_back(temp1);
    }
    start.push_back(max(temp1, ties[n] - current[n - 1]));
    for (int i = n - 1; i >= 0; i--) {
        temp2 = max(temp2, ties[i + 1] - current[i]);
        shifted.push_back(temp2);
    }
    reverse(shifted.begin(), shifted.end());
    //indexing issue below?
    for (int i = 0; i <= n; i++) {
        cout << max(start[i], shifted[i]) << ' ';
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -