Submission #30523

#TimeUsernameProblemLanguageResultExecution timeMemory
30523laptop_recaiBoxes with souvenirs (IOI15_boxes)C++98
100 / 100
581 ms171048 KiB
//Bismillahirrahmanirrahim #include<bits/stdc++.h> #include<bits/stdc++.h> #define fori(A,B,C) for(int A=B; A<C; ++A) #define ford(A,B,C) for(int A=B; A>=C; --A) #define fi first #define se second #define pb push_back #define pbp(A,B) pb({A,B}) #define pp(A,B) push({A,B}) using namespace std; typedef long long ll; const ll linf = 1e18; vector < ll > l, r; #include "boxes.h" long long delivery(int N, int k, int L, int p[]) { fori(i,0,N) { if(p[i] <= L>>1) l.pb(p[i]<<1); else r.pb((L - p[i])<<1); } reverse(r.begin(), r.end()); int lsz = l.size(); int rsz = r.size(); fori(i,k,lsz) l[i] += l[i - k]; fori(i,k,rsz) r[i] += r[i - k]; ll ans = (lsz ? l.back() : 0) + (rsz ? r.back() : 0); for(int i = 0; i <= k; i++) { ans = min(ans, (i < l.size() ? l[l.size() - 1 - i] : 0) + ((k-i) < r.size() ? r[r.size() - 1 - (k-i)] : 0) + L); } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:25:18: warning: conversion to 'int' from 'std::vector<long long int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
  int lsz = l.size();
            ~~~~~~^~
boxes.cpp:26:18: warning: conversion to 'int' from 'std::vector<long long int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
  int rsz = r.size();
            ~~~~~~^~
boxes.cpp:33:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   ans = min(ans, (i < l.size() ? l[l.size() - 1 - i] : 0) + ((k-i) < r.size() ?  r[r.size() - 1 - (k-i)] : 0) + L);
                   ~~^~~~~~~~~~
boxes.cpp:33:68: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   ans = min(ans, (i < l.size() ? l[l.size() - 1 - i] : 0) + ((k-i) < r.size() ?  r[r.size() - 1 - (k-i)] : 0) + L);
                                                              ~~~~~~^~~~~~~~~~
#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...