Submission #1242065

#TimeUsernameProblemLanguageResultExecution timeMemory
1242065M_SH_ORoom Temperature (JOI24_ho_t1)C++20
Compilation error
0 ms0 KiB
/*#pragma GCC optimize("O3")
#pragma GCC optimization("Ofast,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")*/
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/

#define ll long long
#define ll1 long long
#define ull unsigned long long
#define dou long double
#define str string
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define vbool vector<bool>
#define vstr vector<str>
#define vvll vector<vll>
#define pb push_back
#define pf push_front
#define endl "\n"
#define fr first
#define se second
// #define sortcmp(a) sort(a.begin(), a.end(), cmp)
#define sort(a) sort(a.begin(), a.end())
#define reverse(a) reverse(a.begin(), a.end())
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define INF 1000000000000000007
#define ordered_set tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
//using namespace __gnu_pbds;

mt19937 rng(time(0));
ll randll(ll l, ll r) {
    return uniform_int_distribution<ll>(l, r)(rng);
}

int main(){
    speed;
    srand(time(0));

    ll n, k;
    cin >> n >> k;

    vll a(n);
    vpll b;
    for (int i = 0; i < n; i ++) {
        cin >> a[i];
        bool q = 0;
        if (a[i] >= k) q = 1;
        b.pb({a[i]%k, q});
    }

    sort(b);
    ll maxl = b.back().fr;
    ll minl = INF, x = -1, y = -1;
    for (int i = 0; i < n; i ++) {
        if (maxl-b[i].fr < minl) {
            minl = maxl-b[i].fr;
        }
        if (b[i].se == 0) break;
        maxl = max(maxl, b[i].fr+k);
    }
    ll mn = b[0].fr;
    for (int i = n-1; i >= 0; i --) {
        minl = min(minl, b[i].fr-mn);
        if (/*#pragma GCC optimize("O3")
#pragma GCC optimization("Ofast,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")*/
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/

#define ll long long
#define ll1 long long
#define ull unsigned long long
#define dou long double
#define str string
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define vbool vector<bool>
#define vstr vector<str>
#define vvll vector<vll>
#define pb push_back
#define pf push_front
#define endl "\n"
#define fr first
#define se second
// #define sortcmp(a) sort(a.begin(), a.end(), cmp)
#define sort(a) sort(a.begin(), a.end())
#define reverse(a) reverse(a.begin(), a.end())
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define INF 1000000000000000007
#define ordered_set tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
//using namespace __gnu_pbds;

mt19937 rng(time(0));
ll randll(ll l, ll r) {
    return uniform_int_distribution<ll>(l, r)(rng);
}

int main(){
    speed;
    srand(time(0));

    ll n, k;
    cin >> n >> k;

    vll a(n);
    vpll b;
    for (int i = 0; i < n; i ++) {
        cin >> a[i];
        bool q = 0;
        if (a[i] >= k) q = 1;
        b.pb({a[i]%k, q});
    }

    sort(b);
    ll maxl = b.back().fr;
    ll minl = INF, x = -1, y = -1;
    for (int i = 0; i < n; i ++) {
        if (maxl-b[i].fr < minl) {
            minl = maxl-b[i].fr;
        }
        if (b[i].se == 0) break;
        maxl = max(maxl, b[i].fr+k);
    }
    ll mn = b[0].fr;
    for (int i = n-1; i >= 0; i --) {
        minl = min(minl, b[i].fr-mn);
        if (b[i].se == 0) break;
        mn = min(mn, b[i].fr-k);
    }

    cout << minl/2+minl%2 << endl;


}

b[i].se == 0) break;
        mn = min(mn, b[i].fr-k);
    }

    cout << minl/2+minl%2 << endl;


}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:100:1: error: expected primary-expression before 'using'
  100 | using namespace std;
      | ^~~~~
Main.cpp:103:12: error: expected initializer before '(' token
  103 | mt19937 rng(time(0));
      |            ^
Main.cpp:103:12: error: expected ')' before '(' token
  103 | mt19937 rng(time(0));
      |            ^
      |            )
Main.cpp:69:12: note: to match this '('
   69 |         if (/*#pragma GCC optimize("O3")
      |            ^
Main.cpp:103:20: error: could not convert 'rng' from 'std::mt19937' {aka 'std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>'} to 'bool'
  103 | mt19937 rng(time(0));
      |                    ^
      |                    |
      |                    std::mt19937 {aka std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>}
Main.cpp:104:23: error: a function-definition is not allowed here before '{' token
  104 | ll randll(ll l, ll r) {
      |                       ^
Main.cpp:108:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
  108 | int main(){
      |         ^~
Main.cpp:108:9: note: remove parentheses to default-initialize a variable
  108 | int main(){
      |         ^~
      |         --
Main.cpp:108:9: note: or replace parentheses with braces to value-initialize a variable
Main.cpp:108:11: error: a function-definition is not allowed here before '{' token
  108 | int main(){
      |           ^
Main.cpp:146:13: error: expected ';' before ')' token
  146 | b[i].se == 0) break;
      |             ^
      |             ;