Submission #707607

#TimeUsernameProblemLanguageResultExecution timeMemory
707607Specialistas13Swimming competition (LMIO18_plaukimo_varzybos)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define FAST_IO cin.tie(nullptr); ios_base::sync_with_stdio(0) int main() { FAST_IO; int n, a, b, current=0, maxi=0, ans=1e7; cin>>n>>a>>b; vector<int> numbers; for (int i=0; i<n; i++){ int a; cin>>a; numbers.push_back(a); } sort(numbers.begin(), numbers.end()); maxi=numbers[n-1]; current=numbers[0]; for (int i=1; i<n; i++){ if (i>=a && i<=b) { if (numbers[i]!=numbers[i-1]) { ans=min(abs(numbers[i]-maxi), abs(numbers[i]-current)); } } } for (int i=n-2; i>=0; i--){ if (i>=a && i<=b) { if (numbers[i]!=numbers[i+1]) { ans=min(abs(numbers[i]-maxi), abs(numbers[i]-current)); } } } cout<<ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...