fix: removing duplicated tests and correcting some small solutions
This commit is contained in:
@@ -2,22 +2,24 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int t;
|
||||
cin >> t;
|
||||
while (t--) {
|
||||
int n;
|
||||
cin >> n;
|
||||
vector<int> nums(n);
|
||||
for (int i = 0; i < n; i++)
|
||||
cin >> nums[i];
|
||||
|
||||
int main(){
|
||||
int t; cin >> t;
|
||||
while (t--) {
|
||||
int n; cin >> n;
|
||||
vector<int> nums(n);
|
||||
for (int i = 0; i < n; i++) cin >> nums[i];
|
||||
|
||||
sort(nums.begin(), nums.end());
|
||||
|
||||
int minDiff = INT_MAX;
|
||||
for (int i = 1; i < n; i++) {
|
||||
minDiff = min(minDiff, nums[i] - nums[i - 1]);
|
||||
}
|
||||
|
||||
cout << minDiff << endl;
|
||||
}
|
||||
return 0;
|
||||
sort(nums.begin(), nums.end());
|
||||
|
||||
int minDiff = numeric_limits<int>::min();
|
||||
for (int i = 1; i < n; i+=2) {
|
||||
minDiff = max(minDiff, nums[i] - nums[i - 1]);
|
||||
}
|
||||
|
||||
cout << minDiff << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user