help me what's wrong with my code ?!

Revision en1, by Amir_20, 2015-10-29 23:38:16

hi(){ excuse me for my trivial question ; can anyone help me and say what's the problem for the answer of "588c" (duff and lifting weights ) ?! ; }

include

using namespace std; int main(){ long n, i, a, m[1001000], b = 0, c = 0;

cin >> n;

for (i = 0; i < n; i++){
    cin >> a;
    m[a]++;
    if (c < a);
       c = a;
}
for (i = 0; i < c; i++){
    m[i] = m[i] % 2;
    m[i + 1] += m[i] / 2;
}
for (i = 0; i < c + 10; i++){
    if (m[i] != 0)
       b++;
}
cout << b;

}

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Amir_20 2015-10-29 23:38:16 541 Initial revision (published)