Sort Threats by Severity and Exploitability
<p>You are given a 2D integer array <code>threats</code>, where each <code>threats[i] = [ID<sub>i</sub>, sev<sub>i</sub>​, exp<sub>i</sub>]</code></p>

<ul>
	<li><code>ID<sub>i</sub></code>: Unique identifier of the threat.</li>
	<li><code>sev<sub>i</sub></code>: Indicates the severity of the threat.</li>
	<li><code>exp<sub>i</sub></code>: Indicates the exploitability of the threat.</li>
</ul>

<p>The<strong> score</strong> of a threat <code>i</code> is defined as: <code>score = 2 &times; sev<sub>i</sub> + exp<sub>i</sub></code></p>

<p>Your task is to return <code>threats</code> sorted in <strong>descending</strong> order of <strong>score</strong>.</p>

<p>If multiple threats have the same score, sort them by <strong>ascending ID</strong>​​​​​​​.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">threats = [[101,2,3],[102,3,2],[103,3,3]]</span></p>

<p><strong>Output:</strong> <span class="example-io">[[103,3,3],[102,3,2],[101,2,3]]</span></p>

<p><strong>Explanation:</strong></p>

<table border="1" bordercolor="#ccc" cellpadding="5" cellspacing="0" style="border-collapse:collapse;">
	<thead>
		<tr>
			<th>Threat</th>
			<th>ID</th>
			<th>sev</th>
			<th>exp</th>
			<th>Score = 2 &times; sev + exp</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td><code>threats[0]</code></td>
			<td>101</td>
			<td>2</td>
			<td>3</td>
			<td>2 &times; 2 + 3 = 7</td>
		</tr>
		<tr>
			<td><code>threats[1]</code></td>
			<td>102</td>
			<td>3</td>
			<td>2</td>
			<td>2 &times; 3 + 2 = 8</td>
		</tr>
		<tr>
			<td><code>threats[2]</code></td>
			<td>103</td>
			<td>3</td>
			<td>3</td>
			<td>2 &times; 3 + 3 = 9</td>
		</tr>
	</tbody>
</table>

<p>Sorted Order: <code>[[103, 3, 3], [102, 3, 2], [101, 2, 3]]</code></p>
</div>

<p><strong class="example">Example 2:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">threats = [[101,4,1],[103,1,5],[102,1,5]]</span></p>

<p><strong>Output:</strong> <span class="example-io">[[101,4,1],[102,1,5],[103,1,5]]</span></p>

<p><strong>Explanation:​​​​​​​</strong></p>

<table border="1" bordercolor="#ccc" cellpadding="5" cellspacing="0" style="border-collapse:collapse;">
	<thead>
		<tr>
			<th>Threat</th>
			<th>ID</th>
			<th>sev</th>
			<th>exp</th>
			<th>Score = 2 &times; sev + exp</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td><code>threats[0]</code></td>
			<td>101</td>
			<td>4</td>
			<td>1</td>
			<td>2 &times; 4 + 1 = 9</td>
		</tr>
		<tr>
			<td><code>threats[1]</code></td>
			<td>103</td>
			<td>1</td>
			<td>5</td>
			<td>2 &times; 1 + 5 = 7</td>
		</tr>
		<tr>
			<td><code>threats[2]</code></td>
			<td>102</td>
			<td>1</td>
			<td>5</td>
			<td>2 &times; 1 + 5 = 7</td>
		</tr>
	</tbody>
</table>

<p><code>threats[1]</code> and <code>threats[2]</code> have same score, thus sort them by ascending ID.</p>

<p>Sorted Order: <code>[[101, 4, 1], [102, 1, 5], [103, 1, 5]]</code></p>
</div>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= threats.length &lt;= 10<sup>5</sup></code></li>
	<li><code>threats[i] == [ID<sub>i</sub>, sev<sub>i</sub>, exp<sub>i</sub>]</code></li>
	<li><code>1 &lt;= ID<sub>i</sub> &lt;= 10<sup>6</sup></code></li>
	<li><code>1 &lt;= sev<sub>i</sub> &lt;= 10<sup>9</sup></code></li>
	<li><code>1 &lt;= exp<sub>i</sub> &lt;= 10<sup>9</sup></code></li>
	<li>All <code>ID<sub>i</sub></code> are <strong>unique</strong></li>
</ul>
Array; Sorting
class Solution {
public:
    vector<vector<int>> sortThreats(vector<vector<int>>& threats) {
        sort(threats.begin(), threats.end(), [](const vector<int>& a, const vector<int>& b) {
            long long score1 = 2LL * a[1] + a[2];
            long long score2 = 2LL * b[1] + b[2];
            if (score1 == score2) {
                return a[0] < b[0];
            }
            return score2 < score1;
        });
        return threats;
    }
};
