Submission #420100

#TimeUsernameProblemLanguageResultExecution timeMemory
420100ismoilovBoxes with souvenirs (IOI15_boxes)C++14
10 / 100
1 ms296 KiB
#include "boxes.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
#define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
#define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--)
#define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--)

ll delivery(int n, int k, int l, int p[]) {
    ll ans = 0;
    if(k == 1){
	    fp(i,0,n){
	    	ans += (min(p[i], l-p[i]) * 2);
		}
		return ans;
	}
	if(k == n){
		int mx = 0, mx1 = 0;
		fp(i,0,n)
			mx = max(mx,p[i]*2);
		fp(i,0,n)
			mx1 = max(mx1, (l-p[i])*2);
		return min(mx, min(mx1, l));
	}
}

Compilation message (stderr)

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:7:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    7 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
boxes.cpp:15:6: note: in expansion of macro 'fp'
   15 |      fp(i,0,n){
      |      ^~
boxes.cpp:7:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    7 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
boxes.cpp:22:3: note: in expansion of macro 'fp'
   22 |   fp(i,0,n)
      |   ^~
boxes.cpp:7:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    7 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
boxes.cpp:24:3: note: in expansion of macro 'fp'
   24 |   fp(i,0,n)
      |   ^~
boxes.cpp:28:1: warning: control reaches end of non-void function [-Wreturn-type]
   28 | }
      | ^
#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...