제출 #589394

#제출 시각아이디문제언어결과실행 시간메모리
589394web선물상자 (IOI15_boxes)C++17
10 / 100
1 ms300 KiB
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>
#include "boxes.h"
using namespace std;

long long delivery(int N, int K, int L, int p[]) {
    if(K == 1)
    {
        long long sum = 0;
        long long maxDist = L/2;
        for(int i = 0; i<N; ++i)
        {
            if(p[i] <= maxDist)
            {
                sum+= p[i];
            }
            else
            {
                sum += L - p[i];
            }
            //cout<<"new sum: "<<sum<<endl;
        }
        
        long long maxTravelled = 0;
        sum*=2;
       /* for(int i = 0; i<N; ++i)
        {
            if(min(p[i], L-p[i]) > maxTravelled)
                maxTravelled = min(p[i], L-p[i]);
        }
        sum -= maxTravelled;
        //cout<<"sum without last "<<sum<<endl;
        sum*=2;
        sum+=maxTravelled;*/
        //cout<<"final sum"<<sum<<endl;
        return sum;
    }
    
    return 0;
}

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:26:19: warning: unused variable 'maxTravelled' [-Wunused-variable]
   26 |         long long maxTravelled = 0;
      |                   ^~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...