Submission #307513

#TimeUsernameProblemLanguageResultExecution timeMemory
307513giorgigagua2006Exercise Deadlines (CCO20_day1problem2)C11
0 / 25
0 ms256 KiB
#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #define task_count 10 int main() { uint8_t swap = 0; uint8_t tasks[task_count] = {0,1,2,3,4,5,6,7,8,9}; uint8_t * cpy_tasks = (uint8_t *)malloc(task_count); uint8_t deadline[task_count] = {2,3,7,1,5,4,9,0,6,8}; memcpy(cpy_tasks, tasks, 10); uint8_t temp; for (size_t i = 0; i < task_count; i++) { if(tasks[i] != cpy_tasks[deadline[i]]) { temp = tasks[i]; tasks[i] = cpy_tasks[deadline[i]]; swap += deadline[i] - i; tasks[deadline[i]] = temp; } } printf("%d", swap); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...