답안 #861022

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
861022 2023-10-15T06:52:38 Z rati Bitaro's travel (JOI23_travel) C++14
5 / 100
3000 ms 1116 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> sightseeing_spots(N);
    for (int i = 0; i < N; i++) {
        cin >> sightseeing_spots[i];
    }

    int Q;
    cin >> Q;

    for (int q = 0; q < Q; q++) {
        int start_coordinate;
        cin >> start_coordinate;

        long long total_distance = 0;
        int current_position = start_coordinate;

        while (!sightseeing_spots.empty()) {
            int nearest_spot = sightseeing_spots[0];
            int min_distance = abs(current_position - nearest_spot);
            
            for (int spot : sightseeing_spots) {
                int distance = abs(current_position - spot);
                if (distance < min_distance || (distance == min_distance && spot < nearest_spot)) {
                    nearest_spot = spot;
                    min_distance = distance;
                }
            }

            total_distance += min_distance;
            current_position = nearest_spot;

            // Remove the visited spot from the list
            sightseeing_spots.erase(find(sightseeing_spots.begin(), sightseeing_spots.end(), nearest_spot));
        }

        cout << total_distance << endl;
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 3 ms 444 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 3 ms 432 KB Output is correct
15 Correct 3 ms 440 KB Output is correct
16 Correct 3 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 3 ms 444 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 3 ms 432 KB Output is correct
15 Correct 3 ms 440 KB Output is correct
16 Correct 3 ms 348 KB Output is correct
17 Execution timed out 3019 ms 1116 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 3 ms 444 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 3 ms 432 KB Output is correct
15 Correct 3 ms 440 KB Output is correct
16 Correct 3 ms 348 KB Output is correct
17 Execution timed out 3019 ms 1116 KB Time limit exceeded
18 Halted 0 ms 0 KB -