Why am i getting wrong answer?

Правка en3, от CandidFlakes, 2023-07-26 20:28:47

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!

Теги lower bound, upper_bound

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский CandidFlakes 2023-07-26 20:28:47 112 Added some more detail to make my doubt clearer. (published)
en2 Английский CandidFlakes 2023-07-26 20:23:51 836 Tiny change: 'this code #include <' -> 'this code \n\n#include <' (saved to drafts)
en1 Английский CandidFlakes 2023-07-25 13:43:46 463 Initial revision (published)