Submission #204057

# Submission time Handle Problem Language Result Execution time Memory
204057 2020-02-24T04:20:11 Z Segtree Boxes with souvenirs (IOI15_boxes) C++14
70 / 100
1871 ms 464880 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<vector<ll> > rua,rub;
ll delivery(int N,int K,int L,int P[]){
	rep(i,K){
		vector<ll> vec;
		rua.push_back(vec);
		rub.push_back(vec);
		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 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 380 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
19 Correct 5 ms 256 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 5 ms 256 KB Output is correct
22 Correct 5 ms 256 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 5 ms 376 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 5 ms 376 KB Output is correct
29 Correct 5 ms 376 KB Output is correct
30 Correct 5 ms 376 KB Output is correct
31 Correct 5 ms 380 KB Output is correct
32 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 380 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
19 Correct 5 ms 256 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 5 ms 256 KB Output is correct
22 Correct 5 ms 256 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 5 ms 376 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 5 ms 376 KB Output is correct
29 Correct 5 ms 376 KB Output is correct
30 Correct 5 ms 376 KB Output is correct
31 Correct 5 ms 380 KB Output is correct
32 Correct 5 ms 376 KB Output is correct
33 Correct 154 ms 28920 KB Output is correct
34 Correct 141 ms 28920 KB Output is correct
35 Correct 78 ms 20484 KB Output is correct
36 Correct 165 ms 28664 KB Output is correct
37 Correct 153 ms 23928 KB Output is correct
38 Correct 145 ms 23672 KB Output is correct
39 Correct 143 ms 28664 KB Output is correct
40 Correct 145 ms 28664 KB Output is correct
41 Correct 170 ms 30328 KB Output is correct
42 Correct 135 ms 23800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 380 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
19 Correct 5 ms 256 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 5 ms 256 KB Output is correct
22 Correct 5 ms 256 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 5 ms 376 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 5 ms 376 KB Output is correct
29 Correct 5 ms 376 KB Output is correct
30 Correct 5 ms 376 KB Output is correct
31 Correct 5 ms 380 KB Output is correct
32 Correct 5 ms 376 KB Output is correct
33 Correct 154 ms 28920 KB Output is correct
34 Correct 141 ms 28920 KB Output is correct
35 Correct 78 ms 20484 KB Output is correct
36 Correct 165 ms 28664 KB Output is correct
37 Correct 153 ms 23928 KB Output is correct
38 Correct 145 ms 23672 KB Output is correct
39 Correct 143 ms 28664 KB Output is correct
40 Correct 145 ms 28664 KB Output is correct
41 Correct 170 ms 30328 KB Output is correct
42 Correct 135 ms 23800 KB Output is correct
43 Correct 1827 ms 464880 KB Output is correct
44 Correct 1312 ms 356512 KB Output is correct
45 Correct 866 ms 223792 KB Output is correct
46 Correct 1672 ms 434940 KB Output is correct
47 Correct 1856 ms 355080 KB Output is correct
48 Correct 1871 ms 352700 KB Output is correct
49 Execution timed out 177 ms 51820 KB Time limit exceeded (wall clock)
50 Halted 0 ms 0 KB -