Submission #429531

#TimeUsernameProblemLanguageResultExecution timeMemory
429531BelguteiWiring (IOI17_wiring)C++17
13 / 100
38 ms3764 KiB
#include "wiring.h"
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define mk make_pair
#define pb push_back

long long min_total_length(std::vector<int> r, std::vector<int> b) {
	ll cc=0;
	for(int i=0; i<b.size(); i++){
		if(b[i]<=r[r.size()-1]) cc=1;
	}
	if(cc==0){
		// subtask 3
		long long ans=0;
		if(r.size()>=b.size()){
			for(int i=0; i<b.size(); i++){
				ans+=b[i]-r[i];
			}
			for(int i=b.size(); i<r.size(); i++){
				ans+=b[0]-r[i];
			}
			return ans;
		}
		else{
			for(int i=0; i<r.size(); i++){
				ans+=b[i]-r[i];
			}
			for(int i=r.size(); i<b.size(); i++){
				ans+=b[i]-r[r.size()-1];
			}
			return ans;
		}
	}
	return 0;
}

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:13:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  for(int i=0; i<b.size(); i++){
      |               ~^~~~~~~~~
wiring.cpp:20:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |    for(int i=0; i<b.size(); i++){
      |                 ~^~~~~~~~~
wiring.cpp:23:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |    for(int i=b.size(); i<r.size(); i++){
      |                        ~^~~~~~~~~
wiring.cpp:29:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |    for(int i=0; i<r.size(); i++){
      |                 ~^~~~~~~~~
wiring.cpp:32:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |    for(int i=r.size(); i<b.size(); i++){
      |                        ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...