Submission #727097

# Submission time Handle Problem Language Result Execution time Memory
727097 2023-04-20T03:51:38 Z iskhakkutbilim Road Closures (APIO21_roads) C++14
0 / 100
29 ms 5028 KB
#include "roads.h"
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
vector<long long> minimum_closure_costs(int N, vector<int> U, vector<int> V, vector<int> W) {
	vector<long long> ans;
	int sub1 = 1, sub2 = 1;
	for(int i = 0;i < N-1; i++){
		if(U[i] != 0) sub1 = 0;
		if(U[i] != i or V[i] != i+1) sub2 = 0;
	}
	int sum = 0LL;
	for(int i = 0;i < N-1; i++) sum+= W[i];
	ans.push_back(sum);
	if(sub1){
		sort(W.begin(), W.end());
//		sum = 0LL;
		for(int i = N - 2;i >= 0; i--){
			sum -= W[i] * 1LL;
			ans.push_back(sum);
		}
	}else if(sub2){
		
	}else{
		
	}
	if(ans.size() != N-1) assert(false);
	return ans;
}


//main(){
//	int N; cin >> N;
//	vector<int> U(N), V(N), W(N);
//	for(int i = 0;i < N-1; i++){
//		cin >> U[i] >> V[i];
//	}
//	for(int i = 0;i < N-1; i++) cin >> W[i];
//	
//	vector<long long> ans = minimum_closure_costs(N, U, V, W);
//	
//}

Compilation message

roads.cpp: In function 'std::vector<long long int> minimum_closure_costs(int, std::vector<int>, std::vector<int>, std::vector<int>)':
roads.cpp:28:16: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |  if(ans.size() != N-1) assert(false);
      |     ~~~~~~~~~~~^~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 5028 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 5028 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -