Submission #13974

#TimeUsernameProblemLanguageResultExecution timeMemory
13974gs14004정전 (OJUZ10_blackout)C++14
20 / 100
140 ms10976 KiB
#include <cstdio> #include <map> using namespace std; map<int,int> mp; int a[100005]; int main(){ int n,l; scanf("%d %d",&n,&l); for (int i=0; i<n; i++) { scanf("%d",&a[i]); mp[a[i]-l]++; mp[a[i]+l]--; } int hi = 0, ret = 0; auto it = mp.begin(); for (auto &i : mp){ hi += i.second; it++; if(hi > 1 && it != mp.end()) ret += it->first - i.first; } printf("%d",ret); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...