ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1025. Democracy in Danger

Compilation error. WHY?
Posted by AKruglyak 22 Feb 2012 00:04
It work in dev c++:

#include <iostream>
using namespace std;
int main(){
    int a;
   cin>>a;
    int b[a];
    int tmp;
    int q=0;
    for(int i=0; i<a; i++){
            cin>>b[i];
            }
            for(int i = 0; i < a - 1; ++i) // i - íîìåð ïðîõîäà
    {
        for(int j = 0; j < a - 1; ++j) // âíóòðåííèé öèêë ïðîõîäà
        {
            if (b[j + 1] < b[j])
            {
                tmp = b[j + 1];
                b[j + 1] = b[j];
                b[j] = tmp;
            }
        }
    }
    if (a%2==0){

           for (int z=0; z<(a/2)+1;z++){
               if(b[z]%2==0)
                       q+=(b[z]/2)+1;
               else
               q+=(b[z]+1)/2;

               }
             }
             else {
                  int r=(a+1)/2;
                 for (int z=0; z<r;z++){
               if(b[z]%2==0)
                       q+=(b[z]/2)+1;
               else
               q+=(b[z]+1)/2;

                  }
}


    cout<<q;
 return 0;
    }