fork download
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. #include <ext/pb_ds/tree_policy.hpp>
  4. using namespace __gnu_pbds;
  5. using namespace std;
  6. #define PI 3.14159265359
  7. #define dmin 1e-9
  8. #define dd double
  9. #define ll long long
  10. #define yes cout << "YES\n"
  11. #define no cout << "NO\n"
  12. #define pb push_back
  13. #define vi vector<ll>
  14. #define vpi vector<pair<ll, int>>
  15. #define srt(a) sort(a.begin(), a.end())
  16. #define rsrt(a) sort(a.rbegin(), a.rend())
  17. #define nn "\n"
  18. #define nl cout << "\n"
  19. #define fast ios_base::sync_with_stdio(false), cin.tie(NULL);
  20. #define loop(i, a, b) for (int i = (a); i < (b); ++i)
  21. #define rloop(i, a, b) for (int i = (a); i <= (b); ++i)
  22. void print(vector<ll> &a) { loop(i, 0, a.size()) cout << a[i] << ' '; }
  23. template <typename T>
  24. using my_ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  25.  
  26. void mdmerazulislam()
  27. {
  28. ll n, k, k1;
  29. cin >> n >> k >> k1;
  30. vi a(n);
  31. loop(i, 0, n) cin >> a[i];
  32. srt(a);
  33. ll s = 0, mx = 0, cnt = n-k1;
  34. loop(i,0,n)
  35. {
  36. if (i < cnt)
  37. s += a[i];
  38. else
  39. s -= a[i];
  40. }
  41.  
  42. ll rst = s;
  43. for (int i = n - 1; i >= n - k; i--)
  44. {
  45. if (i >= cnt)
  46. {
  47. s += a[i];
  48. if (cnt - 1 >= 0)
  49. s -= 2 * a[cnt - 1];
  50. cnt--;
  51. rst = max(s, rst);
  52. }
  53. }
  54. cout << rst << endl;
  55.  
  56.  
  57. }
  58.  
  59. int main()
  60. {
  61. fast;
  62.  
  63. int t;
  64. cin >> t;
  65. while (t--)
  66. mdmerazulislam();
  67.  
  68. return 0;
  69. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, or enum expected
#include <bits/stdc++.h>
         ^
Main.java:2: error: illegal character: '#'
#include <ext/pb_ds/assoc_container.hpp>
^
Main.java:3: error: illegal character: '#'
#include <ext/pb_ds/tree_policy.hpp>
^
Main.java:5: error: class, interface, or enum expected
using namespace std;
^
Main.java:6: error: illegal character: '#'
#define PI 3.14159265359
^
Main.java:6: error: class, interface, or enum expected
#define PI 3.14159265359
        ^
Main.java:7: error: illegal character: '#'
#define dmin 1e-9
^
Main.java:8: error: illegal character: '#'
#define dd double
^
Main.java:9: error: illegal character: '#'
#define ll long long
^
Main.java:10: error: illegal character: '#'
#define yes cout << "YES\n"
^
Main.java:11: error: illegal character: '#'
#define no cout << "NO\n"
^
Main.java:12: error: illegal character: '#'
#define pb push_back
^
Main.java:13: error: illegal character: '#'
#define vi vector<ll>
^
Main.java:14: error: illegal character: '#'
#define vpi vector<pair<ll, int>>
^
Main.java:15: error: illegal character: '#'
#define srt(a) sort(a.begin(), a.end())
^
Main.java:16: error: illegal character: '#'
#define rsrt(a) sort(a.rbegin(), a.rend())
^
Main.java:17: error: illegal character: '#'
#define nn "\n"
^
Main.java:18: error: illegal character: '#'
#define nl cout << "\n"
^
Main.java:19: error: illegal character: '#'
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL);
^
Main.java:20: error: illegal character: '#'
#define loop(i, a, b) for (int i = (a); i < (b); ++i)
^
Main.java:20: error: class, interface, or enum expected
#define loop(i, a, b) for (int i = (a); i < (b); ++i)
        ^
Main.java:20: error: class, interface, or enum expected
#define loop(i, a, b) for (int i = (a); i < (b); ++i)
                                        ^
Main.java:20: error: class, interface, or enum expected
#define loop(i, a, b) for (int i = (a); i < (b); ++i)
                                                 ^
Main.java:21: error: illegal character: '#'
#define rloop(i, a, b) for (int i = (a); i <= (b); ++i)
^
Main.java:21: error: class, interface, or enum expected
#define rloop(i, a, b) for (int i = (a); i <= (b); ++i)
                                         ^
Main.java:21: error: class, interface, or enum expected
#define rloop(i, a, b) for (int i = (a); i <= (b); ++i)
                                                   ^
Main.java:22: error: class, interface, or enum expected
void print(vector<ll> &a) { loop(i, 0, a.size()) cout << a[i] << ' '; }
                                                                      ^
Main.java:26: error: class, interface, or enum expected
void mdmerazulislam()
^
Main.java:29: error: class, interface, or enum expected
    cin >> n >> k >> k1;
    ^
Main.java:30: error: class, interface, or enum expected
    vi a(n);
    ^
Main.java:31: error: class, interface, or enum expected
    loop(i, 0, n) cin >> a[i];
    ^
Main.java:32: error: class, interface, or enum expected
    srt(a);
    ^
Main.java:33: error: class, interface, or enum expected
    ll s = 0, mx = 0, cnt = n-k1;
    ^
Main.java:34: error: class, interface, or enum expected
    loop(i,0,n)
    ^
Main.java:38: error: class, interface, or enum expected
        else
        ^
Main.java:40: error: class, interface, or enum expected
    }
    ^
Main.java:43: error: class, interface, or enum expected
    for (int i = n - 1; i >= n - k; i--)
    ^
Main.java:43: error: class, interface, or enum expected
    for (int i = n - 1; i >= n - k; i--)
                        ^
Main.java:43: error: class, interface, or enum expected
    for (int i = n - 1; i >= n - k; i--)
                                    ^
Main.java:48: error: class, interface, or enum expected
            if (cnt - 1 >= 0)
            ^
Main.java:50: error: class, interface, or enum expected
            cnt--;
            ^
Main.java:51: error: class, interface, or enum expected
            rst = max(s, rst);
            ^
Main.java:52: error: class, interface, or enum expected
        }
        ^
Main.java:57: error: class, interface, or enum expected
}
^
Main.java:63: error: class, interface, or enum expected
    int t;
    ^
Main.java:64: error: class, interface, or enum expected
    cin >> t;
    ^
Main.java:65: error: class, interface, or enum expected
    while (t--)
    ^
Main.java:68: error: class, interface, or enum expected
    return 0;
    ^
Main.java:69: error: class, interface, or enum expected
}
^
50 errors
stdout
Standard output is empty