제출 #346020

#제출 시각아이디문제언어결과실행 시간메모리
346020emaborevkovic선물상자 (IOI15_boxes)C++14
100 / 100
581 ms193696 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ss second #define ff first #define mp make_pair #define pb push_back const int N = 1e7+1; vector <int> a, b; ll osta[N], ostb[N]; ll delivery(int n, int k, int l, int positions[N]) { int mid = l/2; ll res = 1e18; a.clear(); b.clear(); for (int i=0;i<k;i++) { osta[i] = 0; ostb[i] = 0; } for (int i=0;i<n;i++) { if (positions[i] > mid) break; a.pb(positions[i]); } for (int i=n-1;i>=0;i--) { if (positions[i] <= mid) break; b.pb(l-positions[i]); } int lijevo = a.size(), desno = b.size(); for (int i=0;i<lijevo;i++) { osta[(i+1)%k] += a[i]*2; } for (int i=0;i<desno;i++) { ostb[(i+1)%k] += b[i]*2; } int lk = lijevo%k, dk = desno%k; res = min(res, osta[lk]+ostb[dk]); for (int i=0;i<=k;i++) { ll sada = l; int mod1 = lk-i; if (mod1 < 0) mod1 += k; int mod2 = dk-(k-i); if (mod2 < 0) mod2 += k; sada += osta[mod1]+ostb[mod2]; res = min(res, sada); } return res; } /* int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); vector <int> v = {1, 2, 5}; cout << delivery(3, 2, 8, v); return 0; } */

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:30:21: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   30 |  int lijevo = a.size(), desno = b.size();
      |               ~~~~~~^~
boxes.cpp:30:39: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   30 |  int lijevo = a.size(), desno = b.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...