CandidFlakes's blog

By CandidFlakes, history, 11 months ago, In English

I was trying to solve this question. After trying enough i finally read the tutorial. Suppose the minimum number, is a[0]=600. Then we need to calculate how many elements of size 2*600-1=1999 can we form i.e. we simply need to divide each of the a[i] by 1999 and add each of them. But this code is giving wrong results.

#include <bits/stdc++.h>
using namespace std;

#define MULTI int _T; cin >> _T; while(_T--)

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    MULTI
    {
      int n;
      cin>>n;
      vector<int> a(n);
      long long sum = 0;
      for(int i=0;i<n;++i)
      {
        cin>>a[i];
      }
      for(int i = 0;i<n;++i)
      {
        sum+=(a[i])/(2*a[0]-1);
      }
      cout<<sum<<endl;
    }
}


I will be thankful for any help!

  • Vote: I like it
  • -6
  • Vote: I do not like it

»
11 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by CandidFlakes (previous revision, new revision, compare).