Submission #154165

# Submission time Handle Problem Language Result Execution time Memory
154165 2019-09-18T16:54:48 Z youssefbou62 Boxes with souvenirs (IOI15_boxes) C++14
0 / 100
2 ms 376 KB
#include  <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab  (int  x ) { return (x>0?x:-x);




ll delivery(int N , int K , int L,int positions[]){
	ll l = L, cur = 0 ,s=0, k = K ; 
	for(int i = 0 ;  i< N ; i++ ){
		if( (l - positions[i])*2 < l-cur )
			s += (l- positions[i])*2 , cur = 0 ,k=K; 
		else 
		s += min(abs(1LL*positions[i]-cur),l-abs(1LL*positions[i]-cur)) , k --;  
		cur = positions[i] ;  
		// k--; 
		if( k == 0 ){
			s += min(cur,l-cur); 
			k = K ; 
			cur = 0 ; 
		}
	}
	if( k && k != K )s += min(cur,l-cur); 
	return s; 
}
// int main(){
// 	int p[]={1,2,5}; 
// 	cout << delivery(3,2,8,p); 
// }
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 248 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 248 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 248 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 248 KB Output isn't correct
3 Halted 0 ms 0 KB -