Submission #1110209

# Submission time Handle Problem Language Result Execution time Memory
1110209 2024-11-09T02:19:28 Z vjudge1 Growing Vegetables is Fun 5 (JOI24_vegetables5) C++17
4 / 100
5000 ms 592 KB
#include<bits/stdc++.h>
using namespace std;
int n;
int a[20],b[20];
bool check(vector<int>&p){
    int f1=0,l1=0;
    int f2=0,l2=0;
    for(int i=2*n-1;i>=0;i--){
        if(p[i]<n)f1=i;
        else f2=i;
    }
    for(int i=0;i<2*n;i++){
        if(p[i]<n)l1=i;
        else l2=i;
    }
    return ((l1-f1)<n||(l2-f2)<n);
}
int cal(vector<int>p){
    int res=0;
    for(int i=0;i<2*n;i++){
        res=max(res,abs(a[i]-b[p[i]]));
    }
    return res;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(fopen("c.INP","r")){
        freopen("c.INP","r",stdin);
        freopen("c.OUT","w",stdout);
    }
    cin >>n;
    vector<int>p;
    for(int i=0;i<2*n;i++){
        cin >>a[i];
        p.push_back(i);
    }
    for(int i=0;i<n;i++){
        cin >>b[i];
    }
    for(int i=n;i<2*n;i++){
        cin >>b[i];
    }
    int asw=2e9+1;
    asw=min(asw,cal(p));
    while(next_permutation(p.begin(),p.end())){
        if(check(p))asw=min(asw,cal(p));
    }
    cout <<asw;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:30:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         freopen("c.INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:31:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         freopen("c.OUT","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 65 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 66 ms 336 KB Output is correct
7 Correct 70 ms 336 KB Output is correct
8 Correct 2 ms 336 KB Output is correct
9 Correct 71 ms 444 KB Output is correct
10 Correct 67 ms 336 KB Output is correct
11 Correct 64 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 66 ms 336 KB Output is correct
7 Correct 70 ms 336 KB Output is correct
8 Correct 2 ms 336 KB Output is correct
9 Correct 71 ms 444 KB Output is correct
10 Correct 67 ms 336 KB Output is correct
11 Correct 64 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Execution timed out 5068 ms 336 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 65 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 66 ms 336 KB Output is correct
7 Correct 70 ms 336 KB Output is correct
8 Correct 2 ms 336 KB Output is correct
9 Correct 71 ms 444 KB Output is correct
10 Correct 67 ms 336 KB Output is correct
11 Correct 64 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Execution timed out 5068 ms 336 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 65 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 66 ms 336 KB Output is correct
7 Correct 70 ms 336 KB Output is correct
8 Correct 2 ms 336 KB Output is correct
9 Correct 71 ms 444 KB Output is correct
10 Correct 67 ms 336 KB Output is correct
11 Correct 64 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Execution timed out 5068 ms 336 KB Time limit exceeded
14 Halted 0 ms 0 KB -