답안 #827551

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
827551 2023-08-16T14:39:16 Z tolbi Roller Coaster Railroad (IOI16_railroad) C++17
0 / 100
65 ms 7608 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#include "railroad.h"
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
long long plan_roller_coaster(vector<int> s, vector<int> t) {
	vector<pair<int,int>> arr;
	for (int i = 0; i < s.size(); i++){
		if (s[i]==t[i]) continue;
		int c = 1;
		if (s[i]<=t[i]){
			c=-1;
		}
		arr.push_back({min(s[i],t[i]),c});
		arr.push_back({max(s[i],t[i])+1,-c});
	}
	sort(arr.begin(), arr.end());
	ll crr = 0;
	int n = arr.size();
	ll ans = 0;
	for (int i = 0; i < n; i++){
		if (i<n-1 && arr[i].first==arr[i+1].first){
			crr+=arr[i].second;
			continue;
		}
		crr+=arr[i].second;
		if (crr>0){
			return 23;
			//ans+=max(1ll,crr)*(ll)(arr[i+1].first-arr[i].first);
		}
	}
	return 0;
	//return ans;
}

Compilation message

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:8:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  for (int i = 0; i < s.size(); i++){
      |                  ~~^~~~~~~~~~
railroad.cpp:20:5: warning: unused variable 'ans' [-Wunused-variable]
   20 |  ll ans = 0;
      |     ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB answer is not correct: 23 instead of 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB answer is not correct: 23 instead of 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 65 ms 7608 KB answer is not correct: 1 instead of 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB answer is not correct: 23 instead of 0
2 Halted 0 ms 0 KB -