Submission #30520

#TimeUsernameProblemLanguageResultExecution timeMemory
30520laptop_recaiBoxes with souvenirs (IOI15_boxes)C++98
10 / 100
3 ms376 KiB
//Bismillahirrahmanirrahim #include<bits/stdc++.h> using namespace std; typedef long long ll; ll sum,ans1,ans2,ans3; int lsz,rsz; vector<ll> l,r; #include "boxes.h" long long delivery(int N, int k, int L, int p[]) { for(int i = 0; i < N; i++) { if(p[i] <= L >> 1) l.push_back(p[i]<<1); else r.push_back((L-p[i])<<1); } for(int i = k-1; i < l.size(); i += k) { sum += l[i]; } for(int i = k-1; i < r.size(); i += k) { sum += r[i]; } lsz = l.size(); rsz = r.size(); ans1 = sum + (rsz%k ? r.back() : 0) + (lsz%k ? l.back() : 0); int x = rsz-1-(k-lsz%k); ans2 = sum + L + (x >= 0 ? r[x] : 0); x = lsz-1-(k-rsz%k); ans3 = sum + L + (x >= 0 ? l[x] : 0); return min(ans1,min(ans2,ans3)); }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:17:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = k-1; i < l.size(); i += k) {
                   ~~^~~~~~~~~~
boxes.cpp:20:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = k-1; i < r.size(); i += k) {
                      ~~^~~~~~~~~~
boxes.cpp:23:17: warning: conversion to 'int' from 'std::vector<long long int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
     lsz = l.size();
           ~~~~~~^~
boxes.cpp:24:17: warning: conversion to 'int' from 'std::vector<long long int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
     rsz = r.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...