Submission #70574

# Submission time Handle Problem Language Result Execution time Memory
70574 2018-08-23T06:22:42 Z Kmcode Wiring (IOI17_wiring) C++14
13 / 100
50 ms 14180 KB
#include <bits/stdc++.h>

using namespace std;


#include "wiring.h"

long long min_total_length(std::vector<int> r, std::vector<int> b) {
	int rr=r.size()-1;
	int bb=0;
	long long int dist=0;
	while(rr<r.size()||bb<b.size()){
		if(bb>=b.size()){
			dist+=b[0]-r[rr];
			rr--;
			continue;
		}
		if(rr<0){
			dist+=b[bb]-r.back();
			bb++;
			continue;
		}
		dist+=b[min((int)b.size()-1,bb)]-r[max(0,rr)];
		rr--;
		bb++;
	}
	return dist;
}

Compilation message

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:12:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while(rr<r.size()||bb<b.size()){
        ~~^~~~~~~~~
wiring.cpp:12:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while(rr<r.size()||bb<b.size()){
                     ~~^~~~~~~~~
wiring.cpp:13:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(bb>=b.size()){
      ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 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 2 ms 356 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 37 ms 2960 KB Output is correct
4 Correct 34 ms 4424 KB Output is correct
5 Correct 39 ms 6004 KB Output is correct
6 Correct 47 ms 8244 KB Output is correct
7 Correct 46 ms 10176 KB Output is correct
8 Correct 49 ms 12240 KB Output is correct
9 Correct 50 ms 14180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 14180 KB Output is correct
2 Incorrect 2 ms 14180 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 2 ms 14180 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 2 ms 248 KB 3rd lines differ - on the 1st token, expected: '25859', found: '-4909'
2 Halted 0 ms 0 KB -