Submission #20242

#TimeUsernameProblemLanguageResultExecution timeMemory
20242jjwdi0정전 (OJUZ10_blackout)C++98
50 / 100
44 ms24 KiB
#include <stdio.h> #include <algorithm> #define INF -1234567891 typedef long long ll; using namespace std; int a[150005], l; int n, i, left=INF, right=INF, t1, t2; ll ans; int f(int x) { return x>0?x:0; } main() { scanf("%d%d", &n, &l); for(i=0; i<n; i++)scanf("%d", a+i); sort(a, a+n); for(i=1; i<n; i++) { if(a[i]-a[i-1]>=2*l)continue; t1=a[i]-l;t2=a[i-1]+l; // printf("%d %d\n", t2-t1, f(right-t1)); ans+=(ll)(t2-t1)-(ll)f(right-t1); left=t1;right=t2; // printf("%lld\n", ans); } printf("%lld", ans); }

Compilation message (stderr)

blackout.cpp:13:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
blackout.cpp: In function 'int main()':
blackout.cpp:15:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &l);
                       ^
blackout.cpp:16:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=0; i<n; i++)scanf("%d", a+i);
                                    ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...