Submission #204055

# Submission time Handle Problem Language Result Execution time Memory
204055 2020-02-24T04:15:54 Z Segtree Boxes with souvenirs (IOI15_boxes) C++14
70 / 100
792 ms 524292 KB
#include"boxes.h"
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
vector<ll> rua[10000010],rub[10000010];
ll delivery(int N,int K,int L,int P[]){
	rep(i,K){
		rua[i].push_back(0);
		rub[i].push_back(0);
	}
	rep(i,N){
		rua[i%K].push_back(rua[i%K].back()+(ll)(P[i]*2));
		rub[i%K].push_back(rub[i%K].back()+(ll)((L-P[i])*2));
	}
	ll ans=1e17;
	for(int i=0;i+K-1<N;i++){
		ll res=L;
		//for(int j=i-1;j>=0;j-=K)res+=P[j]*2;
		int a=i-1;
		if(a>=0){
			res+=rua[a%K][a/K+1];
		}
		
		//for(int j=i+K;j<N;j+=K)res+=(L-P[j])*2;
		int b=i+K;
		if(b<N){
			res+=rub[b%K].back()-rub[b%K][b/K];
		}
		chmin(ans,res);
	}
	for(int i=0;i<=N;i++){
		ll res=0;
		//for(int j=i-1;j>=0;j-=K)res+=P[j]*2;
		int a=i-1;
		if(a>=0){
			res+=rua[a%K][a/K+1];
		}
		
		//for(int j=i;j<N;j+=K)res+=(L-P[j])*2;
		int b=i;
		if(b<N){
			res+=rub[b%K].back()-rub[b%K][b/K];
		}
		chmin(ans,res);
	}
	return ans;
}
/*
int main(){
	int n,k,l,p[110];
	cin>>n>>k>>l;
	rep(i,n){
		cin>>p[i];
	}
	cout<<delivery(n,k,l,p)<<endl;
}*/


# Verdict Execution time Memory Grader output
1 Correct 281 ms 470012 KB Output is correct
2 Correct 287 ms 470008 KB Output is correct
3 Correct 280 ms 470008 KB Output is correct
4 Correct 291 ms 470144 KB Output is correct
5 Correct 279 ms 470008 KB Output is correct
6 Correct 289 ms 470008 KB Output is correct
7 Correct 286 ms 470008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 289 ms 470008 KB Output is correct
2 Correct 288 ms 470136 KB Output is correct
3 Correct 279 ms 470008 KB Output is correct
4 Correct 283 ms 470136 KB Output is correct
5 Correct 281 ms 470144 KB Output is correct
6 Correct 278 ms 470008 KB Output is correct
7 Correct 290 ms 470136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 296 ms 470008 KB Output is correct
2 Correct 286 ms 470136 KB Output is correct
3 Correct 287 ms 470008 KB Output is correct
4 Correct 281 ms 470008 KB Output is correct
5 Correct 283 ms 470008 KB Output is correct
6 Correct 289 ms 470008 KB Output is correct
7 Correct 291 ms 470136 KB Output is correct
8 Correct 280 ms 470008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 281 ms 470012 KB Output is correct
2 Correct 287 ms 470008 KB Output is correct
3 Correct 280 ms 470008 KB Output is correct
4 Correct 291 ms 470144 KB Output is correct
5 Correct 279 ms 470008 KB Output is correct
6 Correct 289 ms 470008 KB Output is correct
7 Correct 286 ms 470008 KB Output is correct
8 Correct 289 ms 470008 KB Output is correct
9 Correct 288 ms 470136 KB Output is correct
10 Correct 279 ms 470008 KB Output is correct
11 Correct 283 ms 470136 KB Output is correct
12 Correct 281 ms 470144 KB Output is correct
13 Correct 278 ms 470008 KB Output is correct
14 Correct 290 ms 470136 KB Output is correct
15 Correct 296 ms 470008 KB Output is correct
16 Correct 286 ms 470136 KB Output is correct
17 Correct 287 ms 470008 KB Output is correct
18 Correct 281 ms 470008 KB Output is correct
19 Correct 283 ms 470008 KB Output is correct
20 Correct 289 ms 470008 KB Output is correct
21 Correct 291 ms 470136 KB Output is correct
22 Correct 280 ms 470008 KB Output is correct
23 Correct 292 ms 470008 KB Output is correct
24 Correct 296 ms 470008 KB Output is correct
25 Correct 286 ms 470008 KB Output is correct
26 Correct 287 ms 470324 KB Output is correct
27 Correct 281 ms 470008 KB Output is correct
28 Correct 281 ms 470012 KB Output is correct
29 Correct 289 ms 470136 KB Output is correct
30 Correct 286 ms 470008 KB Output is correct
31 Correct 286 ms 470156 KB Output is correct
32 Correct 281 ms 470008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 281 ms 470012 KB Output is correct
2 Correct 287 ms 470008 KB Output is correct
3 Correct 280 ms 470008 KB Output is correct
4 Correct 291 ms 470144 KB Output is correct
5 Correct 279 ms 470008 KB Output is correct
6 Correct 289 ms 470008 KB Output is correct
7 Correct 286 ms 470008 KB Output is correct
8 Correct 289 ms 470008 KB Output is correct
9 Correct 288 ms 470136 KB Output is correct
10 Correct 279 ms 470008 KB Output is correct
11 Correct 283 ms 470136 KB Output is correct
12 Correct 281 ms 470144 KB Output is correct
13 Correct 278 ms 470008 KB Output is correct
14 Correct 290 ms 470136 KB Output is correct
15 Correct 296 ms 470008 KB Output is correct
16 Correct 286 ms 470136 KB Output is correct
17 Correct 287 ms 470008 KB Output is correct
18 Correct 281 ms 470008 KB Output is correct
19 Correct 283 ms 470008 KB Output is correct
20 Correct 289 ms 470008 KB Output is correct
21 Correct 291 ms 470136 KB Output is correct
22 Correct 280 ms 470008 KB Output is correct
23 Correct 292 ms 470008 KB Output is correct
24 Correct 296 ms 470008 KB Output is correct
25 Correct 286 ms 470008 KB Output is correct
26 Correct 287 ms 470324 KB Output is correct
27 Correct 281 ms 470008 KB Output is correct
28 Correct 281 ms 470012 KB Output is correct
29 Correct 289 ms 470136 KB Output is correct
30 Correct 286 ms 470008 KB Output is correct
31 Correct 286 ms 470156 KB Output is correct
32 Correct 281 ms 470008 KB Output is correct
33 Correct 394 ms 499192 KB Output is correct
34 Correct 366 ms 499064 KB Output is correct
35 Correct 355 ms 490756 KB Output is correct
36 Correct 407 ms 507896 KB Output is correct
37 Correct 405 ms 503228 KB Output is correct
38 Correct 406 ms 503356 KB Output is correct
39 Correct 417 ms 506632 KB Output is correct
40 Correct 387 ms 501880 KB Output is correct
41 Correct 411 ms 509832 KB Output is correct
42 Correct 383 ms 497144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 281 ms 470012 KB Output is correct
2 Correct 287 ms 470008 KB Output is correct
3 Correct 280 ms 470008 KB Output is correct
4 Correct 291 ms 470144 KB Output is correct
5 Correct 279 ms 470008 KB Output is correct
6 Correct 289 ms 470008 KB Output is correct
7 Correct 286 ms 470008 KB Output is correct
8 Correct 289 ms 470008 KB Output is correct
9 Correct 288 ms 470136 KB Output is correct
10 Correct 279 ms 470008 KB Output is correct
11 Correct 283 ms 470136 KB Output is correct
12 Correct 281 ms 470144 KB Output is correct
13 Correct 278 ms 470008 KB Output is correct
14 Correct 290 ms 470136 KB Output is correct
15 Correct 296 ms 470008 KB Output is correct
16 Correct 286 ms 470136 KB Output is correct
17 Correct 287 ms 470008 KB Output is correct
18 Correct 281 ms 470008 KB Output is correct
19 Correct 283 ms 470008 KB Output is correct
20 Correct 289 ms 470008 KB Output is correct
21 Correct 291 ms 470136 KB Output is correct
22 Correct 280 ms 470008 KB Output is correct
23 Correct 292 ms 470008 KB Output is correct
24 Correct 296 ms 470008 KB Output is correct
25 Correct 286 ms 470008 KB Output is correct
26 Correct 287 ms 470324 KB Output is correct
27 Correct 281 ms 470008 KB Output is correct
28 Correct 281 ms 470012 KB Output is correct
29 Correct 289 ms 470136 KB Output is correct
30 Correct 286 ms 470008 KB Output is correct
31 Correct 286 ms 470156 KB Output is correct
32 Correct 281 ms 470008 KB Output is correct
33 Correct 394 ms 499192 KB Output is correct
34 Correct 366 ms 499064 KB Output is correct
35 Correct 355 ms 490756 KB Output is correct
36 Correct 407 ms 507896 KB Output is correct
37 Correct 405 ms 503228 KB Output is correct
38 Correct 406 ms 503356 KB Output is correct
39 Correct 417 ms 506632 KB Output is correct
40 Correct 387 ms 501880 KB Output is correct
41 Correct 411 ms 509832 KB Output is correct
42 Correct 383 ms 497144 KB Output is correct
43 Runtime error 792 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
44 Halted 0 ms 0 KB -