Skip to content

Commit ba8fc67

Browse files
committed
added Submission link
1 parent c60a96e commit ba8fc67

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

Problems/Mathematics/Day-02/sol/Sudhanshu/Solution1.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,24 @@ int main()
88
ios::sync_with_stdio(false);
99
cin.tie(NULL);
1010

11-
int t;
11+
ll t;
1212
cin >> t;
1313
while (t--)
1414
{
15-
int n;
15+
ll n;
1616
cin >> n;
17-
vector<int> v(n);
17+
vector<ll> v(n);
1818

19-
for (int i = 0; i < n; i++)
19+
for (ll i = 0; i < n; i++)
2020
cin >> v[i];
2121

2222
sort(v.begin(), v.end());
2323

24-
int low = v[0];
25-
int high = v[n - 1];
24+
ll low = v[0];
25+
ll high = v[n - 1];
2626

27-
int adjust = (low == high) ? 2 : 1;
28-
29-
int cLow = 0;
30-
int cHigh = 0;
27+
ll cLow = 0;
28+
ll cHigh = 0;
3129

3230
for (auto i : v)
3331
{
@@ -44,7 +42,7 @@ int main()
4442
cHigh++;
4543
}
4644

47-
cout << cHigh * cLow * 2 / adjust << endl;
45+
cout << ((low == high) ? (cLow * (cLow - 1)) : (cLow * cHigh * 2)) << endl;
4846
}
4947

5048
return 0;
@@ -62,4 +60,6 @@ int main()
6260
6361
TC: O(nlog n)
6462
SC: O(n)
63+
64+
https://codeforces.com/contest/1771/submission/355619015
6565
*/

0 commit comments

Comments
 (0)