Submission #1101643

# Submission time Handle Problem Language Result Execution time Memory
1101643 2024-10-16T13:15:00 Z modwwe Measures (CEOI22_measures) C++17
100 / 100
149 ms 36292 KB
#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC optimize("conserve-stack")
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define NHP     ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe  int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
#define getchar_unlocked getchar

inline int scan()
{
    char c = getchar_unlocked();
    int x = 0;
    while (c < '0' || c > '9')
    {
        c = getchar_unlocked();
    }
    while (c >= '0' && c <= '9')
    {
        x = (x << 1) + (x << 3) + c - '0';
        c = getchar_unlocked();
    }
    return x;
}

void phongbeo();
const int inf = 1e9;
const int mod2 = 1e9 + 7;
const int  mod1 = 998244353;
struct icd
{
    long double a;
    int b;
};
struct ib
{
    int a;
    int b;
};
struct ic
{
    int a, b, c;
};
struct id
{
    int a, b, c, d;
};
struct ie
{
    int a, b, c, d, e;

};

int n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, mid, l2, r2, center;
int  i, s10, s12,k1,k2,k3,s11,limit,w,l,r,last,root;
int kk;
int el = 19;

main()
{
    if(fopen(task".inp","r"))
    {
        fin(task);
        fou(task);
    }
    NHP
    /// cin>>s1;
///modwwe
    phongbeo();
    // checktime
}
struct seg
{
    int a,b;
    int cnt;
    int mx;
    void init(int x)
    {
        cnt=1;
        a=-x;
        b=k-x;
    }
}
t[800101];
int a[201000];
vector<pair<int,int>>v;
seg mer(seg a,seg b)
{
    seg c;
    c.a=min(b.a,a.a-k*b.cnt);
    c.b=max(b.b+a.cnt*k,a.b);
    c.cnt=a.cnt+b.cnt;
    c.mx=max({a.mx,b.mx,b.b-a.a});
    return c;
}
void upd(int node,int l,int r,int l1)
{
    if(l==r)
    {
        t[node].init(v[l-1].first);
        return;
    }
    int mid=l+r>>1;
    if(l1<=mid) upd(node<<1,l,mid,l1);
    else upd(node<<1|1,mid+1,r,l1);
         t[node]=mer(t[node<<1],t[node<<1|1]);

}
void upd(int x)
{
    upd(1,1,n,x);
    if(v[x-1].second>mx)
    {
        cout<<t[1].mx/2;
        if(t[1].mx%2==1)cout<<".5";
        cout<<" ";

    }
}
void phongbeo()
{
    cin>>n>>m>>k;
    mx=n;
    n+=m;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        v.pb({a[i],i});
    }
    sort(v.begin(),v.end());
    for(int i=1; i<=n; i++)
        a[i]=lower_bound(v.begin(),v.end(),make_pair(a[i],i))-v.begin()+1;
   for(int i=1;i<=n*4;i++)
    t[i].a=inf,t[i].mx=0,t[i].b=-inf,t[i].cnt=0;
    for(int i=1; i<=n; i++)
    {
        upd(a[i]);

    }
}

Compilation message

Main.cpp:69:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   69 | main()
      | ^~~~
Main.cpp: In function 'void upd(long long int, long long int, long long int, long long int)':
Main.cpp:113:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  113 |     int mid=l+r>>1;
      |             ~^~
Main.cpp:115:5: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
  115 |     else upd(node<<1|1,mid+1,r,l1);
      |     ^~~~
Main.cpp:116:10: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
  116 |          t[node]=mer(t[node<<1],t[node<<1|1]);
      |          ^
Main.cpp: In function 'void phongbeo()':
Main.cpp:143:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  143 |    for(int i=1;i<=n*4;i++)
      |    ^~~
Main.cpp:145:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  145 |     for(int i=1; i<=n; i++)
      |     ^~~
Main.cpp: In function 'int main()':
Main.cpp:13:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 | #define fin(x) freopen(x".inp","r",stdin)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:73:9: note: in expansion of macro 'fin'
   73 |         fin(task);
      |         ^~~
Main.cpp:14:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 | #define fou(x) freopen(x".out","w",stdout)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:74:9: note: in expansion of macro 'fou'
   74 |         fou(task);
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2388 KB Output is correct
2 Correct 1 ms 2388 KB Output is correct
3 Correct 1 ms 2388 KB Output is correct
4 Correct 2 ms 2812 KB Output is correct
5 Correct 1 ms 2388 KB Output is correct
6 Correct 1 ms 2388 KB Output is correct
7 Correct 2 ms 2552 KB Output is correct
8 Correct 1 ms 2388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2388 KB Output is correct
2 Correct 1 ms 2388 KB Output is correct
3 Correct 1 ms 2388 KB Output is correct
4 Correct 2 ms 2812 KB Output is correct
5 Correct 1 ms 2388 KB Output is correct
6 Correct 1 ms 2388 KB Output is correct
7 Correct 2 ms 2552 KB Output is correct
8 Correct 1 ms 2388 KB Output is correct
9 Correct 119 ms 33100 KB Output is correct
10 Correct 121 ms 33212 KB Output is correct
11 Correct 66 ms 33228 KB Output is correct
12 Correct 97 ms 33216 KB Output is correct
13 Correct 64 ms 32724 KB Output is correct
14 Correct 67 ms 33216 KB Output is correct
15 Correct 126 ms 32444 KB Output is correct
16 Correct 67 ms 33216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 75 ms 34236 KB Output is correct
2 Correct 83 ms 36096 KB Output is correct
3 Correct 90 ms 36176 KB Output is correct
4 Correct 84 ms 33984 KB Output is correct
5 Correct 78 ms 35260 KB Output is correct
6 Correct 77 ms 34304 KB Output is correct
7 Correct 81 ms 35360 KB Output is correct
8 Correct 74 ms 33988 KB Output is correct
9 Correct 77 ms 33980 KB Output is correct
10 Correct 81 ms 36292 KB Output is correct
11 Correct 78 ms 34748 KB Output is correct
12 Correct 80 ms 35772 KB Output is correct
13 Correct 80 ms 33984 KB Output is correct
14 Correct 81 ms 35748 KB Output is correct
15 Correct 87 ms 35724 KB Output is correct
16 Correct 75 ms 33468 KB Output is correct
17 Correct 80 ms 35260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 75 ms 34236 KB Output is correct
2 Correct 83 ms 36096 KB Output is correct
3 Correct 90 ms 36176 KB Output is correct
4 Correct 84 ms 33984 KB Output is correct
5 Correct 78 ms 35260 KB Output is correct
6 Correct 77 ms 34304 KB Output is correct
7 Correct 81 ms 35360 KB Output is correct
8 Correct 74 ms 33988 KB Output is correct
9 Correct 77 ms 33980 KB Output is correct
10 Correct 81 ms 36292 KB Output is correct
11 Correct 78 ms 34748 KB Output is correct
12 Correct 80 ms 35772 KB Output is correct
13 Correct 80 ms 33984 KB Output is correct
14 Correct 81 ms 35748 KB Output is correct
15 Correct 87 ms 35724 KB Output is correct
16 Correct 75 ms 33468 KB Output is correct
17 Correct 80 ms 35260 KB Output is correct
18 Correct 144 ms 34208 KB Output is correct
19 Correct 149 ms 36028 KB Output is correct
20 Correct 84 ms 36028 KB Output is correct
21 Correct 111 ms 33984 KB Output is correct
22 Correct 115 ms 34492 KB Output is correct
23 Correct 85 ms 34236 KB Output is correct
24 Correct 135 ms 34708 KB Output is correct
25 Correct 74 ms 33980 KB Output is correct
26 Correct 135 ms 33816 KB Output is correct
27 Correct 134 ms 36284 KB Output is correct
28 Correct 96 ms 34236 KB Output is correct
29 Correct 114 ms 35704 KB Output is correct
30 Correct 104 ms 33840 KB Output is correct
31 Correct 100 ms 35772 KB Output is correct
32 Correct 81 ms 35772 KB Output is correct
33 Correct 121 ms 33532 KB Output is correct
34 Correct 100 ms 35100 KB Output is correct