답안 #176024

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
176024 2020-01-07T15:54:23 Z Peacher29 선물상자 (IOI15_boxes) C++14
100 / 100
1113 ms 524288 KB
#include "boxes.h"
#include<bits/stdc++.h>

using namespace std;

class pont{
public:
	int elotte;
	int utana;
	int hely;
	
	long long vissza;
	
	long long elolrol;
	long long hatulrol;
};

vector<pont> p;

long long delivery(int n, int k, int l, int in[]) {
	p.resize(n+1);
	for(int i=0;i<=n;i++){
		p[i].elotte = (i-1+n+1)%(n+1);
		p[i].utana = (i+1)%(n+1);
	}
	p[0].hely=0;
	for(int i=1;i<=n;i++){
		p[i].hely=in[i-1];
	}
	long long eddig=0; 
	for(int i=1;i<=n;i++){
		p[i].vissza= min (
			p[i].hely, l-p[i].hely
		);
		//cout << i << ':' << p[i].vissza << '\t';
		/*if((i-1)%k==0){
			eddig+=p[i].hely+p[i].vissza;
			p[i].elolrol=eddig;
		} else {
			eddig+=p[i].hely-p[p[i].elotte].hely;
			p[i].elolrol=eddig+p[i].vissza;
		}
		cout << i << ' ' << p[i].elolrol << '\n';*/
		p[i].elolrol=p[max(i-k,0)].elolrol+p[i].hely+p[i].vissza;
/*		if(i%k==0){
			eddig+=p[i].hely-p[p[i].elotte].hely+p[i].vissza;
			p[i].elolrol=eddig;
		} else if(i%k==1){
			eddig+=p[i].hely;
			p[i].elolrol=eddig+p[i].vissza;
		} else {
			eddig+=p[i].hely-p[p[i].elotte].hely;
			p[i].elolrol=eddig+p[i].vissza;
		}
		cout << i << ' ' << (i)%k << ' ' << eddig << ' ' << p[i].elolrol << '\n';*/
	}
	if(k==1){
		long long ossz=0;
		for(int i=1;i<=n;i++){
			ossz+=p[i].vissza;
		}
		return ossz*2;
	}
	eddig=0;
	p[0].hely=l;
	for(int i=n;i>0;i--){
		int mit=i+k;
		if(i+k > n){
			mit=0;
		}
		p[i].hatulrol=p[mit].hatulrol+l-p[i].hely+p[i].vissza;
/*		if((n-i+1+k)%k==0){
			eddig+=p[p[i].utana].hely-p[i].hely+p[i].vissza;
			p[i].hatulrol=eddig;
		} else if((n-i+1+k)%k==1){
			eddig+=l-p[i].hely;
			p[i].hatulrol=eddig+p[i].vissza;
		} else {
			eddig+=p[p[i].utana].hely-p[i].hely;
			p[i].hatulrol=eddig+p[i].vissza;
		}*/
		//cout << i << ' ' << (n-i+1+k)%k << ' ' << eddig << ' ' << p[i].hatulrol << '\n';
	}
	long long mn= LLONG_MAX;
	for(int i=0;i<=n;i++){
		mn = min(p[i].elolrol+p[p[i].utana].hatulrol,mn);
	}
return mn;
}

Compilation message

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:30:12: warning: variable 'eddig' set but not used [-Wunused-but-set-variable]
  long long eddig=0; 
            ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 0 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 296 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 0 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 296 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 380 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 0 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 0 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 296 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 380 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 0 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 106 ms 53096 KB Output is correct
34 Correct 71 ms 45304 KB Output is correct
35 Correct 75 ms 45816 KB Output is correct
36 Correct 104 ms 53112 KB Output is correct
37 Correct 105 ms 53140 KB Output is correct
38 Correct 105 ms 53112 KB Output is correct
39 Correct 98 ms 51576 KB Output is correct
40 Correct 81 ms 46968 KB Output is correct
41 Correct 105 ms 53112 KB Output is correct
42 Correct 82 ms 47352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 0 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 296 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 380 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 0 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 106 ms 53096 KB Output is correct
34 Correct 71 ms 45304 KB Output is correct
35 Correct 75 ms 45816 KB Output is correct
36 Correct 104 ms 53112 KB Output is correct
37 Correct 105 ms 53140 KB Output is correct
38 Correct 105 ms 53112 KB Output is correct
39 Correct 98 ms 51576 KB Output is correct
40 Correct 81 ms 46968 KB Output is correct
41 Correct 105 ms 53112 KB Output is correct
42 Correct 82 ms 47352 KB Output is correct
43 Correct 1113 ms 524288 KB Output is correct
44 Correct 813 ms 450476 KB Output is correct
45 Correct 759 ms 458284 KB Output is correct
46 Correct 1111 ms 504548 KB Output is correct
47 Correct 1072 ms 509164 KB Output is correct
48 Correct 1043 ms 511516 KB Output is correct
49 Correct 1064 ms 503412 KB Output is correct
50 Correct 890 ms 467440 KB Output is correct
51 Correct 1101 ms 520144 KB Output is correct
52 Correct 881 ms 470044 KB Output is correct