Submission #238779

#TimeUsernameProblemLanguageResultExecution timeMemory
238779lakshith_Boxes with souvenirs (IOI15_boxes)C++14
20 / 100
5 ms384 KiB
#include <bits/stdc++.h> #define ll long long #define f first #define s second using namespace std; inline void io_setup(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } inline ll Min(ll a,ll b){ return a<b?a:b; } inline ll Max(ll a,ll b){ return a>b?a:b; } ll delivery(int n,int k,int L,int positions[]){ ll ans; if(k==1){ ans = 0; for(int i=0;i<n;i++){ ans += 2*Min(positions[i],L-positions[i]); } }else if(k==n){ pair<int,int> l,r; for(int i=0;i<n;i++){ if(positions[i]<(L/2)){ l.f = Min(positions[i],l.f); l.s = Max(positions[i],l.s); }else{ r.f = Min(L-positions[i],r.f); r.s = Max(L-positions[i],r.s); } } ans = min(L,2*r.s+2*l.s); } return ans; } // int main(){ // io_setup(); // int arr[] = {5,98}; // cout << delivery(2,2,100,arr); // }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:28:18: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
         l.f = Min(positions[i],l.f);
               ~~~^~~~~~~~~~~~~~~~~~
boxes.cpp:29:18: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
         l.s = Max(positions[i],l.s);
               ~~~^~~~~~~~~~~~~~~~~~
boxes.cpp:31:18: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
         r.f = Min(L-positions[i],r.f);
               ~~~^~~~~~~~~~~~~~~~~~~~
boxes.cpp:32:18: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
         r.s = Max(L-positions[i],r.s);
               ~~~^~~~~~~~~~~~~~~~~~~~
boxes.cpp:37:10: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   return ans;
          ^~~
#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...