제출 #945922

#제출 시각아이디문제언어결과실행 시간메모리
945922Nika533선물상자 (IOI15_boxes)C++14
35 / 100
3 ms600 KiB
#pragma GCC diagnostic warning "-std=c++11" #include <bits/stdc++.h> #include "boxes.h" #define pb push_back #define f first #define s second #define MOD 1000000007 #define flush fflush(stdout) #define all(x) (x).begin(),(x).end() #define allr(x) (x).rbegin(), (x).rend() #define pii pair<int,int> using namespace std; int n,m,T,k; long long delivery(int N, int K, int L, int p[]) { if (K==1) { long long ans=0; for (int i=0; i<N; i++) { ans+=min(p[i],L-p[i])*2; } return ans; } if (K==N) { long long ans=0; vector<pii> v1,v2; for (int i=0; i<N; i++) { if (p[i]<L/2) v1.pb({p[i],i}); else v2.pb({p[i],i}); } sort(all(v1)); sort(all(v2)); int l1=0,l2=0; if (v1.size()) l1=v1.back().f; if (v2.size()) l2=L-v2[0].f; ans=min(L,l1*2+l2*2); return ans; } long long ans=1e18; for (int mask=0; mask<(1<<N); mask++) { vector<int> v1,v2; for (int j=0; j<N; j++) { if (mask&(1<<j)) v1.pb(p[j]); else v2.pb(L-p[j]); } long long ans2=0; sort(all(v1)); sort(all(v2)); for (int i=v1.size()-1; i>=0; i-=K) { ans2+=min(v1[i]*2,L); } for (int i=v2.size()-1; i>=0; i-=K) { ans2+=min(v2[i]*2,L); } ans=min(ans,ans2); } return ans; }

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

boxes.cpp:1:32: warning: '-std=c++11' is not an option that controls warnings [-Wpragmas]
    1 | #pragma GCC diagnostic warning "-std=c++11"
      |                                ^~~~~~~~~~~~
boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:45:23: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   45 |   for (int i=v1.size()-1; i>=0; i-=K) {
      |              ~~~~~~~~~^~
boxes.cpp:48:23: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   48 |   for (int i=v2.size()-1; i>=0; i-=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...