fork download
  1. #include<stdio.h>
  2. #include<math.h>
  3. #include<iostream>
  4. #include<algorithm>
  5. using namespace std;
  6. __int64 s[10009];
  7.  
  8. int main()
  9. {
  10. __int64 n;
  11. while(scanf("%I64d",&n)!=EOF)
  12. {
  13. int i,j;
  14. __int64 add=0,all=0;
  15. for(i=1;i<=n;i++)
  16. {
  17. scanf("%I64d",&s[i]);
  18. add+=s[i];
  19. }
  20.  
  21. sort(&s[1],&s[n+1]);
  22. for(i=1;i<n;i++)
  23. {
  24. add-=s[i];
  25. all+=(add-s[i]*(n-i))*2;
  26. }
  27.  
  28. printf("%I64d\n",all);
  29. }
  30. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:3:19: error: iostream: No such file or directory
prog.c:4:20: error: algorithm: No such file or directory
prog.c:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘namespace’
prog.c:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘s’
prog.c: In function ‘main’:
prog.c:10: error: ‘__int64’ undeclared (first use in this function)
prog.c:10: error: (Each undeclared identifier is reported only once
prog.c:10: error: for each function it appears in.)
prog.c:10: error: expected ‘;’ before ‘n’
prog.c:11: error: ‘n’ undeclared (first use in this function)
cc1: warnings being treated as errors
prog.c:11: error: ISO C does not support the 'I' scanf flag
prog.c:14: error: expected ‘;’ before ‘add’
prog.c:17: error: ‘s’ undeclared (first use in this function)
prog.c:17: error: ISO C does not support the 'I' scanf flag
prog.c:18: error: ‘add’ undeclared (first use in this function)
prog.c:21: error: implicit declaration of function ‘sort’
prog.c:25: error: ‘all’ undeclared (first use in this function)
prog.c:28: error: ISO C does not support the 'I' printf flag
prog.c:13: error: unused variable ‘j’
stdout
Standard output is empty