Submission #72631

# Submission time Handle Problem Language Result Execution time Memory
72631 2018-08-26T12:54:02 Z idan_izmirli Wiring (IOI17_wiring) C++14
20 / 100
73 ms 5556 KB
#include "wiring.h"

using namespace std;


long long inline mmin(long long a,long long b)
{
	if(a<b)
	{
		return a;
	}
	return b;
}

long long inline mabs(long long a)
{
	if(a<0)
	{
		return -a;
	}
	return a;
}

long long best[200][200];



long long min_total_length(std::vector<int> r, std::vector<int> b) {
	if((r.size()<=200)&&(b.size()<=200))
	{
		for(int i=0;i<r.size();i++)
		{
			for(int j=0;j<b.size();j++)
			{
				best[i][j]=mabs(r[i]-b[j]);
				if(i==0)
				{
					if(j!=0)
					{
						best[i][j]+=best[i][j-1];
					}
				}
				else if(j==0)
				{
					best[i][j]+=best[i-1][j];
				}
				else
				{
					best[i][j]+=mmin(mmin(best[i-1][j],best[i][j-1]),best[i-1][j-1]);
				}
			}
		}
		return best[r.size()-1][b.size()-1];
	}
	long long result=0;
	long long blue,red;
	for(int i=0;(i<r.size())||(i<b.size());i++)
	{
		if(i>=r.size())
		{
			red=r[r.size()-1];
		}
		else
		{
			red=r[i];
		}
		if(i>=b.size())
		{
			blue=b[0];
		}
		else
		{
			blue=b[b.size()-1-i];
		}
		result+=blue-red;
	}
	return result;
}

Compilation message

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:31:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<r.size();i++)
               ~^~~~~~~~~
wiring.cpp:33:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j=0;j<b.size();j++)
                ~^~~~~~~~~
wiring.cpp:57:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;(i<r.size())||(i<b.size());i++)
               ~^~~~~~~~~
wiring.cpp:57:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;(i<r.size())||(i<b.size());i++)
                             ~^~~~~~~~~
wiring.cpp:59:7: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(i>=r.size())
      ~^~~~~~~~~~
wiring.cpp:67:7: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(i>=b.size())
      ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 396 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 3 ms 516 KB Output is correct
7 Correct 2 ms 1012 KB Output is correct
8 Correct 2 ms 1012 KB Output is correct
9 Correct 4 ms 1128 KB Output is correct
10 Correct 5 ms 1128 KB Output is correct
11 Correct 4 ms 1128 KB Output is correct
12 Correct 3 ms 1128 KB Output is correct
13 Correct 5 ms 1128 KB Output is correct
14 Correct 4 ms 1128 KB Output is correct
15 Correct 4 ms 1128 KB Output is correct
16 Correct 5 ms 1128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1128 KB Output is correct
2 Correct 2 ms 1128 KB Output is correct
3 Correct 36 ms 1944 KB Output is correct
4 Correct 36 ms 1944 KB Output is correct
5 Correct 33 ms 1944 KB Output is correct
6 Correct 73 ms 2328 KB Output is correct
7 Correct 41 ms 2328 KB Output is correct
8 Correct 66 ms 2328 KB Output is correct
9 Correct 47 ms 2456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2456 KB Output is correct
2 Correct 3 ms 2456 KB Output is correct
3 Incorrect 43 ms 4248 KB 3rd lines differ - on the 1st token, expected: '1068938599', found: '-303948787415'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4248 KB Output is correct
2 Incorrect 32 ms 5556 KB 3rd lines differ - on the 1st token, expected: '373710605', found: '2074975518'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 396 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 3 ms 516 KB Output is correct
7 Correct 2 ms 1012 KB Output is correct
8 Correct 2 ms 1012 KB Output is correct
9 Correct 4 ms 1128 KB Output is correct
10 Correct 5 ms 1128 KB Output is correct
11 Correct 4 ms 1128 KB Output is correct
12 Correct 3 ms 1128 KB Output is correct
13 Correct 5 ms 1128 KB Output is correct
14 Correct 4 ms 1128 KB Output is correct
15 Correct 4 ms 1128 KB Output is correct
16 Correct 5 ms 1128 KB Output is correct
17 Correct 3 ms 1128 KB Output is correct
18 Correct 2 ms 1128 KB Output is correct
19 Correct 36 ms 1944 KB Output is correct
20 Correct 36 ms 1944 KB Output is correct
21 Correct 33 ms 1944 KB Output is correct
22 Correct 73 ms 2328 KB Output is correct
23 Correct 41 ms 2328 KB Output is correct
24 Correct 66 ms 2328 KB Output is correct
25 Correct 47 ms 2456 KB Output is correct
26 Correct 3 ms 2456 KB Output is correct
27 Correct 3 ms 2456 KB Output is correct
28 Incorrect 43 ms 4248 KB 3rd lines differ - on the 1st token, expected: '1068938599', found: '-303948787415'
29 Halted 0 ms 0 KB -