제출 #407319

#제출 시각아이디문제언어결과실행 시간메모리
407319MDario선물상자 (IOI15_boxes)C++11
10 / 100
1 ms332 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; #define F first #define S second long long delivery(int n, int k, int l, int p[]){ vector<pair<ll, ll>> v1, v2; v1.push_back({0, 0}); v2.push_back({0, 0}); for(int i=0; i<n; i++){ if(p[i]!=0){ if(p[i]<=l/2)v1.push_back({p[i], 0}); } } for(int i=n-1; i>=0; i--){ if(p[i]!=0){ if(p[i]>l/2)v2.push_back({l-p[i], 0}); } } for(int i=0; i<v1.size(); i++){ if(i<k)v1[i].S=v1[i].F*2; else v1[i].S=v1[i].F*2+v1[i-k].S; } for(int i=0; i<v2.size(); i++){ if(i<k)v2[i].S=v2[i].F*2; else v2[i].S=v2[i].F*2+v2[i-k].S; } ll r=v1.back().S+v2.back().S; for(int i=0; i<v1.size()&&i<k; i++){ int c=v1.size()-1-i, c1; c1=(k-c%k)%k; if(c1>=v1.size()){ r=min(r, v1[c].S+l); } else{ r=min(r, v1[c].S+l+v2[v2.size()-c1-1].S); } } return r; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:21:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for(int i=0; i<v1.size(); i++){
      |                  ~^~~~~~~~~~
boxes.cpp:25:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(int i=0; i<v2.size(); i++){
      |                  ~^~~~~~~~~~
boxes.cpp:30:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int i=0; i<v1.size()&&i<k; i++){
      |                  ~^~~~~~~~~~
boxes.cpp:31:26: warning: conversion from 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   31 |         int c=v1.size()-1-i, c1;
      |               ~~~~~~~~~~~^~
boxes.cpp:33:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         if(c1>=v1.size()){
      |            ~~^~~~~~~~~~~
#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...