fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define mod 1000000007
  4.  
  5.  
  6. int main()
  7. #define int long long
  8. {
  9.  
  10. ios::sync_with_stdio(false);
  11. #ifndef ONLINE_JUDGE
  12. freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
  13. #endif
  14. int t = 1;
  15. cin>>t;
  16. while(t--)
  17. {
  18. int p , q , r;
  19. cin>> p >> q >> r;
  20. int a[p];
  21. int b[q];
  22. int c[r];
  23. int cuma[p +2 ];
  24. int cumc[r + 2];
  25. for(int i=0;i<p;i++)
  26. cin>>a[i];
  27. for(int i=0;i<q;i++)
  28. cin>>b[i];
  29. for(int i=0;i<r;i++)
  30. cin>>c[i];
  31. sort(a,a+p);
  32. //sort(b,b+q);
  33. sort(c,c+r);
  34. cuma[0] = 0;
  35. for(int i=1;i<=p;i++)
  36. {
  37. cuma[i] = (cuma[i-1] + a[i-1]) % mod;
  38. }
  39. cumc[0] = 0;
  40. for(int i=1;i<=r;i++)
  41. {
  42. cumc[i] = (cumc[i-1] + c[i-1]) % mod;
  43. }
  44. int result = 0;
  45. for( int i =0; i<q ; i++)
  46. {
  47. int nolessa = (upper_bound(a, a+p, b[i]) - a);
  48. int nolessc = (upper_bound(c, c+r, b[i]) - c);
  49. //cout<<nolessa<<" "<<nolessc<<endl;
  50. result += ( ( cuma[nolessa] + (nolessa*b[i]) % mod )%mod * ( cumc[nolessc] + (nolessc*b[i]) % mod )%mod );
  51. result = result%mod;
  52. }
  53. cout<<result%mod<<endl;
  54.  
  55. }
  56.  
  57. //https://w...content-available-to-author-only...f.com/viewsolution/14080914
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:55:1: error: expected ‘}’ at end of input
 }
 ^
stdout
Standard output is empty