제출 #112978

#제출 시각아이디문제언어결과실행 시간메모리
112978andremfq선물상자 (IOI15_boxes)C++17
10 / 100
3 ms512 KiB
#include<bits/stdc++.h> #include"boxes.h" #define debug(args...) //fprintf(stderr,args) using namespace std; const int MAXN=10000010; int N,K,L,POS[MAXN]; long long int RESP,resp; vector<long long int> v1,v2; long long int delivery(int n,int k,int l,int pos[]) { long long int resp1=0,resp2=0,resp3=0,resp4=0; int qtdk=0,qtdk2=0,qtdk3=0; sort(pos,pos+n); for(int i=0;i<n;i++) { if(l/2>=pos[i]) v1.push_back(pos[i]); else v2.push_back(pos[i]); } for(int i=0;i<v1.size();i++) debug("v1[%d] = %d\n",i,v1[i]); debug("\n\n"); for(int i=0;i<v2.size();i++) debug("v2[%d] = %d\n",i,v2[i]); debug("\n\n"); for(int i=0;i<v1.size();i++) { qtdk++; if(qtdk==k) qtdk=0, resp1+=2*v1[i]; } debug("resp = %d\n",resp1); int suv=(qtdk==0) ? 0 : k-qtdk; debug("suv = %d\n",suv); resp2+=l; for(int i=v2.size()-1;i>=suv;i--) { debug("RESP2 = %d\n",resp2); debug("I = %d\n",i); qtdk2++; if(i==suv && qtdk2!=k) resp2+=2*(l-v2[i]); if(qtdk2==k) qtdk2=0, resp2+=2*(l-v2[i]); } debug("resp2 = %d\n",resp2); for(int i=v2.size()-1;i>=0;i--) { qtdk3++; if(i==0 && qtdk3!=k) resp3+=2*(l-v2[i]); if(qtdk3==k) qtdk2=0, resp3+=2*(l-v2[i]); } debug("resp3 = %d\n",resp3); for(int i=(v1.size()%k==0) ? k-1 : v1.size()%k-1;i<v1.size();i+=k) { if(i<0) continue; resp3+=2*v1[i]; } debug("resp3 = %d\n",resp3); resp=min(resp1+resp2,resp3); return resp; } /* int main () { scanf("%d %d %d",&N,&K,&L); for(int i=0;i<N;i++) scanf("%d",&POS[i]); RESP=delivery(N,K,L,POS); printf("%lld",RESP); } /* 3 2 8 1 2 5 */

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

boxes.cpp:86:1: warning: "/*" within comment [-Wcomment]
 /*
  
boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:24:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<v1.size();i++) debug("v1[%d] = %d\n",i,v1[i]);
              ~^~~~~~~~~~
boxes.cpp:27:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<v2.size();i++) debug("v2[%d] = %d\n",i,v2[i]);
              ~^~~~~~~~~~
boxes.cpp:30:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<v1.size();i++)
              ~^~~~~~~~~~
boxes.cpp:42:21: warning: conversion to 'int' from 'std::vector<long long int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
  for(int i=v2.size()-1;i>=suv;i--)
            ~~~~~~~~~^~
boxes.cpp:53:21: warning: conversion to 'int' from 'std::vector<long long int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
  for(int i=v2.size()-1;i>=0;i--)
            ~~~~~~~~~^~
boxes.cpp:62:29: warning: conversion to 'int' from 'std::vector<long long int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
  for(int i=(v1.size()%k==0) ? k-1 : v1.size()%k-1;i<v1.size();i+=k)
            ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
boxes.cpp:62:52: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=(v1.size()%k==0) ? k-1 : v1.size()%k-1;i<v1.size();i+=k)
                                                   ~^~~~~~~~~~
boxes.cpp:13:40: warning: unused variable 'resp4' [-Wunused-variable]
  long long int resp1=0,resp2=0,resp3=0,resp4=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...