Timus Problem 1025 (Democracy in Danger) Solution

Timus Problem Solution

Timus problem 1025 Democracy in Danger :

This problem is for beginner.

Problem Details: http://acm.timus.ru/problem.aspx?space=1&num=1025

Problem Description: This is a Straightforward problem.

Timus Problem 1025 Solution

#include<stdio.h>

int main()

{

int i,j,k,a,swap,n,sum=0,array[101];

scanf("%d\n",&n);

for(i=0;i<n;i++)

{

scanf("%d",&array[i]);

}

for(i=0;i<n-1;i++)

{

for(j=0;j<n-i-1;j++)

{

if(array[j]>array[j+1])

{



swap=array[j];

array[j]=array[j+1];

array[j+1]=swap;

}

}

}

k=i/2+1;

for(a=0;a<k;a++)

{

sum+=array[a]/2+1;

}

printf("\n%d",sum);

return 0;

}



 

0 Comments

You may find interest following article

Complete Guide: Create Laravel Project in Docker Without Local Dependencies

Create Laravel Project Through Docker — No Need to Install PHP, MySQL, or Apache on Your Local Machine In this tutorial, I’ll show you how to create and run a full Laravel project using Docker containers. That means you won’t have to install PHP, MySQL, or Apache locally on your computer. By the end of this guide, you’ll have a fully functional Laravel development...