Submission #108614

# Submission time Handle Problem Language Result Execution time Memory
108614 2019-04-30T10:55:55 Z abil Wiring (IOI17_wiring) C++14
7 / 100
407 ms 14940 KB
#include <bits/stdc++.h>

#include "wiring.h"
#define mk make_pair
#define sc second
#define fr first
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define Scan(a) scanf ("%I64d", &a)
#define scan(a) scanf ("%d", &a)

using namespace std;

const long long INF = (int)1e18 + 7;
const int N = (int)1e5 + 12;
const int mod = 1000000007;

int dp[1111][1111] , red[N], blue[N];
long long min_total_length(std::vector<int > r, std::vector<int > b){
      int n = r.size(), m = b.size();

      for(int i = 1;i <= n; i++){
            red[i] = r[i - 1];
      }
      for(int i = 1;i <= m; i++){
            blue[i] = b[i - 1];
      }
      if(red[n] < blue[1]){
            int ans = 0;
            if(n >= m){
                  for(int i = 1;i <= m; i++){
                        ans += abs(blue[i] - red[n - i + 1]);
                  }
                  int i = m;
                  while((n - i)){
                        ans += abs(blue[1] - red[n - i]);
                        i++;
                  }
                  return ans;
            }
            else{
                 for(int i = 1;i <= n; i++){
                        ans += abs(blue[i] - red[n - i + 1]);
                  }
                  int i = n + 1;
                  while((m - n)){
                        ans += abs(blue[i] - red[n]);
                        i++;
                  }
                  return ans;
            }
      }
      else{
            memset(dp,0x3f3f3f3f,sizeof(dp));
            dp[0][0] = 0;
            for(int i = 1;i <= n; i++){
                  for(int j = 1;j <= m; j++){
                       dp[i][j] = min({dp[i - 1][j - 1],dp[i - 1][j],dp[i][j - 1]}) + abs(red[i] - blue[j]);
                  }
            }
            return dp[n][m];
      }

}

# Verdict Execution time Memory Grader output
1 Correct 6 ms 5120 KB Output is correct
2 Correct 6 ms 5120 KB Output is correct
3 Correct 6 ms 5120 KB Output is correct
4 Correct 6 ms 5120 KB Output is correct
5 Correct 6 ms 5120 KB Output is correct
6 Correct 6 ms 5120 KB Output is correct
7 Correct 6 ms 5120 KB Output is correct
8 Correct 7 ms 5120 KB Output is correct
9 Correct 7 ms 5120 KB Output is correct
10 Correct 7 ms 5120 KB Output is correct
11 Correct 6 ms 5120 KB Output is correct
12 Correct 6 ms 5120 KB Output is correct
13 Correct 6 ms 5120 KB Output is correct
14 Correct 6 ms 5120 KB Output is correct
15 Correct 7 ms 5120 KB Output is correct
16 Correct 6 ms 5120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Incorrect 26 ms 2152 KB 3rd lines differ - on the 1st token, expected: '41596985758595', found: '227496835'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 6 ms 5120 KB Output is correct
3 Runtime error 407 ms 14844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 5120 KB Output is correct
2 Runtime error 340 ms 14940 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 5120 KB Output is correct
2 Correct 6 ms 5120 KB Output is correct
3 Correct 6 ms 5120 KB Output is correct
4 Correct 6 ms 5120 KB Output is correct
5 Correct 6 ms 5120 KB Output is correct
6 Correct 6 ms 5120 KB Output is correct
7 Correct 6 ms 5120 KB Output is correct
8 Correct 7 ms 5120 KB Output is correct
9 Correct 7 ms 5120 KB Output is correct
10 Correct 7 ms 5120 KB Output is correct
11 Correct 6 ms 5120 KB Output is correct
12 Correct 6 ms 5120 KB Output is correct
13 Correct 6 ms 5120 KB Output is correct
14 Correct 6 ms 5120 KB Output is correct
15 Correct 7 ms 5120 KB Output is correct
16 Correct 6 ms 5120 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Incorrect 26 ms 2152 KB 3rd lines differ - on the 1st token, expected: '41596985758595', found: '227496835'
20 Halted 0 ms 0 KB -