Submission #337118

# Submission time Handle Problem Language Result Execution time Memory
337118 2020-12-18T14:24:33 Z pggp Wiring (IOI17_wiring) C++14
13 / 100
48 ms 3948 KB
#include <bits/stdc++.h>
#include "wiring.h"

using namespace std;

long long min_total_length(vector < int > r, vector < int > b){
	long long last_r = r[r.size() - 1];
	long long first_b = b[0];
	long long ans = 0;
	for(long long i = 0; i < min(r.size(), b.size()); i++){
		ans += (long long)(b[i] - r[i]);
		if(i == r.size() - 1){
			// łączę wszystkie niebieksie do ostatniego r
			for (long long j = i + 1; j < b.size(); ++j)
			{
				ans += (long long)b[j] - last_r;
			}
			return ans;
		}
		if(i == b.size() - 1){
			// łączę wszystkie czerwone do pierwszego b
			for (long long j = i + 1; j < r.size(); ++j)
			{
				ans += first_b - (long long)r[j];
			}
		return ans;
		}
	}
	return ans;
}

Compilation message

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:10:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'const long unsigned int' [-Wsign-compare]
   10 |  for(long long i = 0; i < min(r.size(), b.size()); i++){
      |                       ~~^~~~~~~~~~~~~~~~~~~~~~~~~
wiring.cpp:12:8: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |   if(i == r.size() - 1){
      |      ~~^~~~~~~~~~~~~~~
wiring.cpp:14:32: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |    for (long long j = i + 1; j < b.size(); ++j)
      |                              ~~^~~~~~~~~~
wiring.cpp:20:8: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   if(i == b.size() - 1){
      |      ~~^~~~~~~~~~~~~~~
wiring.cpp:22:32: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |    for (long long j = i + 1; j < r.size(); ++j)
      |                              ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB 3rd lines differ - on the 1st token, expected: '25859', found: '-4909'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 35 ms 1516 KB Output is correct
4 Correct 20 ms 1516 KB Output is correct
5 Correct 27 ms 1664 KB Output is correct
6 Correct 33 ms 3820 KB Output is correct
7 Correct 27 ms 3820 KB Output is correct
8 Correct 34 ms 3820 KB Output is correct
9 Correct 48 ms 3948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB 3rd lines differ - on the 1st token, expected: '17703', found: '-19052'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB 3rd lines differ - on the 1st token, expected: '27', found: '12'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB 3rd lines differ - on the 1st token, expected: '25859', found: '-4909'
2 Halted 0 ms 0 KB -