| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1358111 | kmath628 | 정전 (OJUZ10_blackout) | C++20 | 17 ms | 996 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int n,l,i;
ll s=0,mx=-2e9;
scanf("%d %d",&n,&l);
vector<int> a(n);
for(i=0;i<n;i++) scanf("%d",&a[i]);
sort(a.begin(),a.end());
for(i=0;i<n-1;i++){
mx=max(mx,(ll)a[i+1]-l);
s+=max(a[i]-mx+l,0ll);
mx=max(mx,(ll)a[i]+l);
}
printf("%lld\n",s);
}
Compilation message (stderr)
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
