MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / solve_elevatr

Function solve_elevatr

CodeChef_problems/ELEVTR/solution.cpp:122–142  ·  view source on GitHub ↗

/

Source from the content-addressed store, hash-verified

120
121/*********************************************************/
122int solve_elevatr(int *B, int Max, int N)
123{ int B2[100000], k, best, res;
124
125 best = -1;
126 /* Do it once with an initial positive direction: */
127 memcpy(B2, B, N*sizeof(int));
128 res = complete_seq(B2, Max, N, 1);
129 if (res >= 0) {
130 if ((best == -1) || (res < best))
131 best = res;
132 }
133
134 /* Repeat with an initial negative direction: */
135 memcpy(B2, B, N*sizeof(int));
136 res = complete_seq(B2, Max, N, -1);
137 if (res >= 0) {
138 if ((best == -1) || (res < best))
139 best = res;
140 }
141 return best;
142}
143
144/********************************************************/
145int elevatr()

Callers 1

elevatrFunction · 0.85

Calls 1

complete_seqFunction · 0.85

Tested by

no test coverage detected