답안 #1011210

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1011210 2024-06-30T06:05:39 Z Pacybwoah Growing Vegetables is Fun 5 (JOI24_vegetables5) C++17
30 / 100
5000 ms 21192 KB
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<cmath>
typedef long long ll;
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> vec(2 * n + 1);
    for(int i = 1; i <= 2 * n; i++) cin >> vec[i];
    vector<int> b(n + 1), c(n + 1);
    for(int i = 1; i <= n; i++) cin >> b[i];
    for(int i = 1; i <= n; i++) cin >> c[i];
    sort(c.begin(), c.end());
    sort(b.begin(), b.end());
    ll ans = 2e18;
    for(int i = 1; i <= n + 1; i++){
        vector<int> tmp;
        for(int j = i; j < i + n; j++) tmp.push_back(vec[j]);
        vector<int> tmp2;
        for(int j = 1; j < i; j++) tmp2.push_back(vec[j]);
        for(int j = i + n; j <= 2 * n; j++) tmp2.push_back(vec[j]);
        sort(tmp.begin(), tmp.end());
        sort(tmp2.begin(), tmp2.end());
        ll sum = 0;
        for(int j = 1; j <= n; j++) sum = max(sum, 1ll * abs(tmp[j - 1] - b[j]));
        for(int j = 1; j <= n; j++) sum = max(sum, 1ll * abs(tmp2[j - 1] - c[j]));
        ans = min(ans, sum);
        sum = 0;
        for(int j = 1; j <= n; j++) sum = max(sum, 1ll * abs(tmp[j - 1] - c[j]));
        for(int j = 1; j <= n; j++) sum = max(sum, 1ll * abs(tmp2[j - 1] - b[j]));
        ans = min(ans, sum);
    }
    cout << ans << "\n";
}
// g++ pC.cpp -std=c++17 -Wshadow -Wall -fsanitize=undefined -fsanitize=address -o run 
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 600 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 604 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 600 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 604 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 181 ms 568 KB Output is correct
27 Correct 181 ms 344 KB Output is correct
28 Correct 97 ms 344 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 188 ms 348 KB Output is correct
31 Correct 171 ms 344 KB Output is correct
32 Correct 48 ms 348 KB Output is correct
33 Correct 10 ms 604 KB Output is correct
34 Correct 185 ms 348 KB Output is correct
35 Correct 178 ms 536 KB Output is correct
36 Correct 189 ms 572 KB Output is correct
37 Correct 71 ms 564 KB Output is correct
38 Correct 89 ms 572 KB Output is correct
39 Correct 103 ms 348 KB Output is correct
40 Correct 200 ms 528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5059 ms 21192 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 600 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 604 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 181 ms 568 KB Output is correct
27 Correct 181 ms 344 KB Output is correct
28 Correct 97 ms 344 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 188 ms 348 KB Output is correct
31 Correct 171 ms 344 KB Output is correct
32 Correct 48 ms 348 KB Output is correct
33 Correct 10 ms 604 KB Output is correct
34 Correct 185 ms 348 KB Output is correct
35 Correct 178 ms 536 KB Output is correct
36 Correct 189 ms 572 KB Output is correct
37 Correct 71 ms 564 KB Output is correct
38 Correct 89 ms 572 KB Output is correct
39 Correct 103 ms 348 KB Output is correct
40 Correct 200 ms 528 KB Output is correct
41 Execution timed out 5059 ms 21192 KB Time limit exceeded
42 Halted 0 ms 0 KB -