Submission #307513

# Submission time Handle Problem Language Result Execution time Memory
307513 2020-09-28T12:19:48 Z giorgigagua2006 Exercise Deadlines (CCO20_day1problem2) C
0 / 25
0 ms 256 KB
#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 time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -