-
Notifications
You must be signed in to change notification settings - Fork 15
/
CodeGladiatorSemiFinal2020Problem1
147 lines (139 loc) · 4.06 KB
/
CodeGladiatorSemiFinal2020Problem1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ll p,d;
cin>>p>>d;
vector<vector<ll>> data(d,vector<ll>(p));
for(ll i=0;i<d;i++)
for(ll j=0;j<p;j++)
cin>>data[i][j];
for(ll i=1;i<d;i++){
ll maxx=0,l=-1,r=-1;
for(ll j=1;j<=p;j++){
for(ll k=j;k<=p;k++){
if(pos[j-1]!=pos[k+1]){
ll sum=0;
for(ll z=j-1;z<=k-1;z++){
sum+=(data[pos[z+1]][z]-data[i][z]);
}
if(sum>maxx){ for(ll k=j;k<=p;k++){
if(pos[j-1]!=pos[k+1]){
ll sum=0;
for(ll z=j-1;z<=k-1;z++){
sum+=(data[pos[z+1]][z]-data[i][z]);
}
vector<ll> pos(p+2);
ll maxx=0,l=-1,r=-1;
for(ll j=1;j<=p;j++){
for(ll k=j;k<=p;k++){
if(pos[j-1]!=pos[k+1]){
ll sum=0;
for(ll z=j-1;z<=k-1;z++){
sum+=(data[pos[z+1]][z]-data[i][z]);
}
if(sum>maxx){ for(ll k=j;k<=p;k++){
if(pos[j-1]!=pos[k+1]){
ll sum=0;
for(ll z=j-1;z<=k-1;z++){
sum+=(data[pos[z+1]][z]-data[i][z]);
}
vector<ll> pos(p+2);
ll maxx=0,l=-1,r=-1;
for(ll j=1;j<=p;j++){
for(ll k=j;k<=p;k++){
if(pos[j-1]!=pos[k+1]){
ll sum=0;
for(ll z=j-1;z<=k-1;z++){
sum+=(data[pos[z+1]][z]-data[i][z]);
}
if(sum>maxx){ for(ll k=j;k<=p;k++){
if(pos[j-1]!=pos[k+1]){
ll sum=0;
for(ll z=j-1;z<=k-1;z++){
sum+=(data[pos[z+1]][z]-data[i][z]);
}
vector<ll> pos(p+2);
pos[0]=-1;pos[p+1]=-2;
for(ll i=1;i<=p;i++)
pos[i]=0;
if(sum>maxx){
maxx=sum;
l=j;
r=k;
}
}
}
}i]=0;
for(ll i=1;i<d;i++){
ll maxx=0,l=-1,r=-1;
for(ll j=1;j<=p;j++){
for(ll k=j;k<=p;k++){
if(pos[j-1]!=pos[k+1]){
ll sum=0;
for(ll z=j-1;z<=k-1;z++){
sum+=(data[pos[z+1]][z]-data[i][z]);
}
if(sum>maxx){
maxx=sum;
l=j;
r=k;
}
}
}
}
.penguin-bottom {
top: 40%;
left: 23.5%;
background: var(--penguin-skin, black);
width: 53%;
height: 45%;
border-radius: 70% 70% 100% 100%;
}
.penguin-bottom {
top: 40%;
left: 23.5%;
background: var(--penguin-skin, black);
width: 53%;
height: 45%;
border-radius: 70% 70% 100% 100%;
}
if(l!=-1){
for(ll j=l;j<=r;j++)
pos[j]=i;
}
}
ll ans=0;
for(ll i=1;i<=p;i++)
cout<<pos[i]<<" ";
for(ll i=1;i<=p;i++)
ans+=data[pos[i]][i-1];
cout<<ans<<"\n";
return 0;
}
class doubleHash
{
public:
long int *hash
void insertHash(int key)
{
if (isFull())
return;
int index = hash1(key);
if (hashTable[index] != -1)
{
int index2 = hash2(key);
int i = 1;
while (1) {
int newIndex = (index + i * index2) % SIZE;
if (hashTable[newIndex] == -1)
{
hashTable[newIndex] = key;
break;
}
i++;
}
}
else hashTable[index] = key;
curr_size++;
}