제출 #238897

#제출 시각아이디문제언어결과실행 시간메모리
238897lakshith_선물상자 (IOI15_boxes)C++14
100 / 100
543 ms206072 KiB
#include <bits/stdc++.h> #define ll long long #define f first #define s second using namespace std; inline void io_setup(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } inline ll Min(ll a,ll b){ return a<b?a:b; } inline ll Max(ll a,ll b){ return a>b?a:b; } ll delivery(int n,int k,int L,int positions[]){ ll ans; if(k==1){ ans = 0; for(int i=0;i<n;i++){ ans += 2*Min(positions[i],L-positions[i]); } }else if(k==n){ pair<int,int> l,r; for(int i=0;i<n;i++){ if(positions[i]<(L/2)){ l.f = Min(positions[i],l.f); l.s = Max(positions[i],l.s); }else{ r.f = Min(L-positions[i],r.f); r.s = Max(L-positions[i],r.s); } } ans = min(L,2*r.s+2*l.s); }else{ ll CW[n]; ll ACW[n]; for(int i=0;i<n;i++){ if(i<k)CW[i]=Min(L,2*positions[i]); else CW[i] = CW[i-k]+Min(L,2*positions[i]); } for(int i=n-1;i>=0;i--){ if(i>=n-k)ACW[i] = Min(L,2*(L-positions[i])); else ACW[i] = Min(L,2*(L-positions[i])) + ACW[i+k]; } ll MIN = Min(CW[n-1],ACW[0]); for(int i=1;i<n-1;i++){ MIN = Min(CW[i]+ACW[i+1],MIN); } ans = MIN; } return ans; } // int main(){ // io_setup(); // int arr[] = {1,2,5}; // cout << delivery(3,2,8,arr); // }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:28:18: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
         l.f = Min(positions[i],l.f);
               ~~~^~~~~~~~~~~~~~~~~~
boxes.cpp:29:18: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
         l.s = Max(positions[i],l.s);
               ~~~^~~~~~~~~~~~~~~~~~
boxes.cpp:31:18: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
         r.f = Min(L-positions[i],r.f);
               ~~~^~~~~~~~~~~~~~~~~~~~
boxes.cpp:32:18: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
         r.s = Max(L-positions[i],r.s);
               ~~~^~~~~~~~~~~~~~~~~~~~
#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...