제출 #260663

#제출 시각아이디문제언어결과실행 시간메모리
260663youssefbou62선물상자 (IOI15_boxes)C++14
컴파일 에러
0 ms0 KiB
#include "boxes.h" #include <bits/stdc++.h> #define ll long long using namespace std; long long delivery(int N, int K, int L, int p[]) { ll ans = 0 ; int m = N,split=0; ll L1 = 1LL*L ; ll P1[N]; for(int i = 0 ; i < N ; i++ )P1[i] = p[i]; for(int i = 0 ; i < N ;i++ ) if( P1[i] > L1/2 ){ m = i ; if( i ) split = (P1[i]-P1[i-1])*2 > L1 ; break ; } int l = -1 , r = N ; for(int i = 0 ; i < m ; i++ ){ if( (i+1) % K == 0 ){ ans += P1[i]*2 ; l = i ; } } for(int i = N-1 ; i >= m ; i-- ){ if( (N-i)%K==0 ){ ans += 2*(L1-P1[i]) ; r = i ; } } // cerr << ans << endl; if( split ){ if( m-1 >= l + 1 ){ ans += P1[m-1]*2 ; } if( m <= r-1 ){ ans += (L1-P1[m])*2; } }else { if( l == m-1 ){ if( r != m )ans += (L1-P1[m])*2 ; } else if( r == m ){ ans += (P1[m-1])*2; } else ans += (r-l-1>K?((L1-P1[m]*2+(P1[m-1])*2):L1)); } return ans; } // int main() { // int N, K, L, i; // cin >> N >> K >> L ; // int p[N] ; // for (i = 0; i < N; i++) { // cin >> p[i] ; // } // cout << delivery(N,K,L,p); // return 0; // }

컴파일 시 표준 에러 (stderr) 메시지

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:52:49: error: expected ')' before ':' token
   else ans += (r-l-1>K?((L1-P1[m]*2+(P1[m-1])*2):L1)); 
                                                 ^
boxes.cpp:52:54: error: expected ':' before ';' token
   else ans += (r-l-1>K?((L1-P1[m]*2+(P1[m-1])*2):L1)); 
                                                      ^
boxes.cpp:52:54: error: expected primary-expression before ';' token
boxes.cpp:52:54: error: expected ')' before ';' token