Submission #99535

# Submission time Handle Problem Language Result Execution time Memory
99535 2019-03-04T19:43:59 Z Sa1loum Cipele (COCI18_cipele) C++14
18 / 90
1000 ms 6904 KB
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mem(a,b) memset(a, b, sizeof(a))
#define F first
#define S second
#define Si size
#define pb(x) push_back(x)
typedef double D;
typedef long long ll;
typedef long double ld;
const int MOD=(int)1e9+7,MAX=(int)1e5+10;
int n,m,a[MAX],b[MAX];
int DP(int i,int j) {
    if (i==n || j==m) return 0;
    return min(DP(i,j+1),max(DP(i+1,j+1),abs(a[i]-b[j])));
}
int main()
{
    scanf("%d%d",&n,&m);
    if (n<m) {
        for (int i=0;i<n;i++) {
            scanf("%d",&a[i]);
        }
        for (int i=0;i<m;i++) {
            scanf("%d",&b[i]);
        }
    }
    else {
        for (int i=0;i<n;i++) {
            scanf("%d",&b[i]);
        }
        for (int i=0;i<m;i++) {
            scanf("%d",&a[i]);
        }
        swap(n,m);
    }
    sort(a,a+n);
    sort(b,b+m);
    if (n==m) {
        int mx=-1;
        for (int i=0;i<n;i++) {
            int o=fabs(a[i]-b[i]);
            mx=max(mx,o);
        }
        cout<<mx<<endl;
        return 0;
    }
    cout<<DP(0,0);

}

Compilation message

cipele.cpp: In function 'int main()':
cipele.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~
cipele.cpp:23:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&a[i]);
             ~~~~~^~~~~~~~~~~~
cipele.cpp:26:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&b[i]);
             ~~~~~^~~~~~~~~~~~
cipele.cpp:31:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&b[i]);
             ~~~~~^~~~~~~~~~~~
cipele.cpp:34:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&a[i]);
             ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 34 ms 2560 KB Output is correct
2 Correct 71 ms 2808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 2808 KB Output is correct
2 Correct 48 ms 2808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1064 ms 512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 640 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 640 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 640 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 640 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 6904 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1070 ms 6904 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1065 ms 6636 KB Time limit exceeded
2 Halted 0 ms 0 KB -