Submission #14185

#TimeUsernameProblemLanguageResultExecution timeMemory
14185ainu7정전 (OJUZ10_blackout)C++98
100 / 100
103 ms2892 KiB
#include <math.h> #include <stdio.h> #include <string.h> #include <vector> #include <string> #include <queue> #include <map> #include <algorithm> #include <cmath> #include <iostream> #include <sstream> #include <set> using namespace std; int main() { long long N, L; cin >> N >> L; L *= 2; vector<long long> V(N); for (int i=0; i<N; i++) { cin >> V[i]; } sort(V.begin(), V.end()); long long p1 = -999999999; long long p2 = -999999999; long long res = 0; for (int i=0; i<N; i++) { res += max(0LL, p2 - max(p1, V[i])); p1 = max(p2, V[i]); p2 = V[i] + L; } cout << res << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...