# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
99722 | 2019-03-06T08:59:06 Z | Sa1loum | Cipele (COCI18_cipele) | C++14 | 270 ms | 203128 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],dp[5050][5050]; int DP(int i,int j) { if (dp[i][j]!=-1) return dp[i][j]; if (i==n && j==m) return dp[i][j]=INT_MIN; if (j==m) return dp[i][j]=INT_MAX; return dp[i][j]=min(DP(i,j+1),max(dp[i+1][j+1],abs(a[i]-b[j]))); } int main() { for (int i=0;i<5050;i++) { for (int j=0;j<5050;j++) { dp[i][j]=-1; } } 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(n-1,m-1); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 112 ms | 102392 KB | Output is correct |
2 | Correct | 143 ms | 102748 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 140 ms | 102612 KB | Output is correct |
2 | Correct | 132 ms | 102724 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 93 ms | 100212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 97 ms | 100200 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 91 ms | 100224 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 98 ms | 100184 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 89 ms | 100192 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 270 ms | 202868 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 258 ms | 203128 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 257 ms | 202748 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |