제출 #754445

#제출 시각아이디문제언어결과실행 시간메모리
754445sofija6선물상자 (IOI15_boxes)C++14
20 / 100
1 ms304 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; long long delivery(int N, int K, int L, int p[]) { deque<int> d; vector<int> leftt,rightt; long long ans=0; for (long long i=0;i<N;i++) d.push_back(p[i]); while (true) { while (!d.empty() && d.front()<=L/2) { leftt.push_back(d.front()); d.pop_front(); if (leftt.size()==K) break; } if (leftt.size()!=K) break; ans+=2*leftt[K-1]; leftt.clear(); } while (true) { while (!d.empty() && d.back()>L/2) { rightt.push_back(d.back()); d.pop_back(); if (rightt.size()==K) break; } if (rightt.size()!=K) break; ans+=2*(L-rightt[K-1]); rightt.clear(); } if (leftt.empty() && rightt.empty()) return ans; if (leftt.empty()) return ans+2*(L-rightt[0]); if (rightt.empty()) return ans+2*leftt[leftt.size()-1]; long long minn=2*leftt[leftt.size()-1]+2*(L-rightt[0]); vector<int> cur=leftt; int lastt=0; for (;lastt<rightt.size();lastt++) { if (cur.size()==K) break; cur.push_back(rightt[lastt]); } minn=min(minn,min(L,2*cur[cur.size()-1])+(lastt==rightt.size()?0ll : 2*(L-rightt[lastt]))); cur=rightt; lastt=leftt.size()-1; for (;lastt>=0;lastt--) { if (cur.size()==K) break; cur.push_back(leftt[lastt]); } minn=min(minn,min(L,2*(L-cur[cur.size()-1]))+(lastt==-1?0ll : 2*leftt[lastt])); return ans+minn; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:17:29: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   17 |             if (leftt.size()==K)
      |                 ~~~~~~~~~~~~^~~
boxes.cpp:20:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |         if (leftt.size()!=K)
      |             ~~~~~~~~~~~~^~~
boxes.cpp:31:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |             if (rightt.size()==K)
      |                 ~~~~~~~~~~~~~^~~
boxes.cpp:34:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |         if (rightt.size()!=K)
      |             ~~~~~~~~~~~~~^~~
boxes.cpp:48:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     for (;lastt<rightt.size();lastt++)
      |           ~~~~~^~~~~~~~~~~~~~
boxes.cpp:50:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   50 |         if (cur.size()==K)
      |             ~~~~~~~~~~^~~
boxes.cpp:54:52: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     minn=min(minn,min(L,2*cur[cur.size()-1])+(lastt==rightt.size()?0ll : 2*(L-rightt[lastt])));
      |                                               ~~~~~^~~~~~~~~~~~~~~
boxes.cpp:56:23: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   56 |     lastt=leftt.size()-1;
      |           ~~~~~~~~~~~~^~
boxes.cpp:59:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   59 |         if (cur.size()==K)
      |             ~~~~~~~~~~^~~
#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...