답안 #100054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
100054 2019-03-09T07:51:15 Z helloworldworld Roller Coaster Railroad (IOI16_railroad) C++14
컴파일 오류
0 ms 0 KB
#include "railroad.h"

long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
    int n = (int) s.size();
    int arr[n];
    for(int i=0;i<n;i++)
        arr[i]=i;
    long long mini,cur;
    for(int i=1;i<n;i++){
        if(t[i-1]>s[i])
            cur+=t[i-1]-s[i];
    }
    mini=cur;
    while(next_permutation(arr,arr+n)){
        for(int i=1;i<n;i++){
            if(t[i-1]>s[i])
                cur+=t[i-1]-s[i];
        }
        if(mini>cur) mini=cur;
    }
    return mini;
}

Compilation message

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:14:11: error: 'next_permutation' was not declared in this scope
     while(next_permutation(arr,arr+n)){
           ^~~~~~~~~~~~~~~~