제출 #30987

#제출 시각아이디문제언어결과실행 시간메모리
30987kajebiii선물상자 (IOI15_boxes)C++14
20 / 100
3 ms380 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; #define SZ(v) ((int)(v).size()) #define ALL(v) (v).begin(),(v).end() #define one first #define two second typedef long long ll; typedef pair<double, double> pd; typedef pair<int, int> pi; typedef pair<ll, int> pli; typedef pair<ll, ll> pll; typedef pair<ll, pi> plp; typedef tuple<int, int, int> ti; typedef tuple<ll, int, int> tli; const int INF = 0x3f2f1f0f; const ll LINF = 1ll * INF * INF * 2; const int MAX_N = 1e7 + 100; int N, K, L, P[MAX_N]; ll Ls[MAX_N], Rs[MAX_N]; deque<int> Ps; ll delivery(int n, int k, int l, int p[]) { N = n; K = k; L = l; for(int i=0; i<N; i++) Ps.push_back(p[i]); while(SZ(Ps) > 0 && Ps.front() == 0) Ps.pop_front(); for(int i=0; i<SZ(Ps); i++) P[i+1] = Ps[i]; N = SZ(Ps); P[0] = 0; P[N+1] = L; for(int i=1; i<=N; i++) { int cnt = i-1; if(cnt % K == 0) Ls[i] = Ls[i-1] + P[i] * 2; else Ls[i] = Ls[i-1] + (P[i] - P[i-1]) * 2; } for(int i=N; i>=1; i--) { int cnt = N - i; if(cnt % K == 0) Rs[i] = Rs[i+1] + (L-P[i]) * 2; else Rs[i] = Rs[i+1] + (P[i+1] - P[i]) * 2; } ll ans = LINF; int rix = N+1; for(int i=1; i<=N; i++) if(P[i] > L/2) {rix = i; break;} for(int i=0; i<rix; i++) { ll val = Ls[i]; int lix = i+1; ll times = ((rix - lix + K-1) / K); val += times * L; lix = min(lix + times * K, 1ll*N+1); val += Rs[lix]; ans = min(ans, val); } return ans; }

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

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:52:18: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
         lix = min(lix + times * K, 1ll*N+1);
               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#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...