1 solutions
-
0
Imported sample code (CPP)
#include <bits/stdc++.h> using namespace std; int main() { vector<int> a(1000001, 0); int x; while (cin >> x) { if (x == 0) break; a[x]++; } int ans1 = 1000000; int min_x = 1000000, max_x = 0, pre_x = -1; for (int i = 1; i <= 1000000; i++) { if (a[i] == 0) continue; min_x = min(min_x, i); max_x = max(max_x, i); if (pre_x != -1) { ans1 = min(ans1, i - pre_x); } pre_x = i; } int ans2 = max_x - min_x; printf("%d %d\n", ans1, ans2); return 0; }
Information
- ID
- 1652
- Time
- 800ms
- Memory
- 64MiB
- Difficulty
- 10
- Tags
- # Submissions
- 2
- Accepted
- 1
- Uploaded By