QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#743846 | #8142. Elevator | Gordensoul | AC ✓ | 358ms | 79232kb | C++23 | 30.3kb | 2024-11-13 20:09:45 | 2024-11-13 20:09:46 |
Judging History
answer
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3, "Ofast", "inline")
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include<array>
#include<random>
using namespace std;
#define for1 for(int i = 1;i <= n;i++)
#define for0 for(int i = 0;i < n;i++)
#define forj1 for(int j = 1;j <= n;j++)
#define forj0 for(int j = 0;j < n;j++)
#define form1 for (int j = 1; j <= m; j++)
#define form0 for (int j = 0; j < m; j++)
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define arrn int* arr = new int[n+2];arr[0] = 0,arr[n+1]=0
#define brrn int* brr = new int[n+2];brr[0] = 0,brr[n+1]=0
#define carr for1 cin >> arr[i]
#define carrn arrn;carr
#define coarr for1 cout<<arr[i]<<" ";cout<<endl
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define blank ' '
#define cn int n;cin>>n
#define cnm int n,m;cin>>n>>m
#define T() int _; cin >> _; while (_--)
#define int long long
#define ll long long
#define pii pair<int,int>
const int mode = 998244353;
const int mod = 1e9 + 7;
mt19937_64 rnd(time(0));
typedef uint64_t hash_t;
//chrono::high_resolution_clock::now().time_since_epoch().count()
int ksm(int a, int b = mode - 2)
{
a %= mode;
int ans = 1;
while (b)
{
if (b % 2 == 1)
{
ans = ans * a % mode; b--;
}
a = a * a % mode;
b >>= 1;
}
return ans;
}
int gcd(int a, int b)
{
if (b == 0)return a;
return gcd(b, a % b);
}
long long lcm(long long a, long long b)
{
return (a * b) / gcd(a, b);
}
//const int mod = 1000002361;
bool ccmp(string x, string y)
{
return x.size() > y.size();
}
long long qpow(int a, int b)
{
a% mod;
if (b == 0)return 1ll;
int ret = 1ll;
while (b)
{
if (b % 2)ret = (ret * a) % mod;
b >>= 1;
a = (a * a) % mod;
}
return ret % mod;
}
int one(int n)//计算二进制下1的个数
{
if (n == 0)return 0;
if (n == 1)return 1;
int ret = 0;
for (int i = 0; i < 63; i++)
{
int w = n / (1ll << (i + 1));
ret = (ret + (w * (1ll << i))) % mode;
int yu = n % (1ll << (i + 1));
if (yu >= 1ll << i)
{
ret = (ret + (yu - (1ll << i) + 1)) % mode;
}
}
return ret % mode;
}
bool isspire(int n)
{
if (n <= 1)return false;
if (n == 2)return true;
for (int i = 2; i <= sqrt(n); i++)
{
if (n % i == 0)return false;
}
return true;
}
void solve();
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
// T()
{
solve();
}
return 0;
}
int tree[500007];
int lowbit(int i)
{
return i&(-i);
}
void add(int i)
{
while (i < 5e5 + 7)
{
tree[i]++;
i += lowbit(i);
}
}
int que(int i)
{
int ret = 0;
while (i)
{
ret += tree[i];
i -= lowbit(i);
}
return ret;
}
void solve() {
int n, m;
cin >> n >> m;
vector<int>a(n + 1);
map<int, int>mp;
for1 cin >> a[i],mp[a[i]]++;
vector<pii>b(n + 1);
for1 b[i] = { a[i],i };
vector<int>sum(n + 1, 0);vector<int>nsum(n + 1, 0);
sort(b.begin() + 1, b.end());
for (int i = 2; i <= n; i++) sum[i] = b[i].first - b[i - 1].first;
for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + sum[i] * (i - 1);
for1 nsum[b[i].second] = sum[i];
int now = 1;
unordered_map<int, int>zz;
for (auto z : mp)
{
zz[z.first] = now++;
}
for1 a[i] = zz[a[i]];
for1
{
add(a[i]);
int need = nsum[i] + que(a[i]) - 1;
if (need > m - 2)cout << "-1\n";
else cout << need << endl;
}
}
//void primeinit() {
// const int N = 0;
// int prime[N], now;
// int minp[N];
// bool vis[N];
// int cnt;
// for (int i = 2; i <= N; ++i)
// {
// if (minp[i] == 0)
// {
// minp[i] = i;
// prime[cnt++] = i;
// }
// for (int j = 0; j < cnt; ++j)
// {
// int p = prime[j];
// if (i * p > N)
// break;
// //if(minp[i*p] == 0)
// minp[i * p] = p;
// if (minp[i] == p)
// break;
// //if(i%p==0) //用这个也可以
// //break;
// }
// }
//}
//const int N = 1e6;
//int prime[N + 9 >> 1], nnow;
//bool vis[N + 9];
//void init() {
// for (int i = 2; i <= N; i++) {
// if (!vis[i])prime[++nnow] = i;
// for (int j = 1; j <= nnow && prime[j] * i <= N; j++) {
// vis[prime[j] * i] = 1;
// if (i % prime[j] == 0)break;
// }
//int arr[1000001];
//int sm[4000004];
//int mx[4000004];
//int mxcnt[4000004];
//int semx[4000004];
////int semxcnt[400004];
//int ad1[4000004];
//int ad2[4000004];
//int ad3[4000004];
//int ad4[4000004];
//int hismx[4000004];
//void up(int i)
//{
// int z = i << 1;
// int y = i << 1 | 1;
// sm[i] = sm[z] + sm[y];
// hismx[i] = max({hismx[z], hismx[y]});
// if (mx[z] > mx[y])
// {
// mx[i] = mx[z];
// mxcnt[i] = mxcnt[z];
// semx[i] = max(mx[y], semx[z]);
// }
// else if (mx[z] < mx[y])
// {
// mx[i] = mx[y];
// mxcnt[i] = mxcnt[y];
// semx[i] = max(mx[z], semx[y]);
// }
// else
// {
// mx[i] = mx[z];
// mxcnt[i] = mxcnt[z] + mxcnt[y];
// semx[i] = max(semx[z], semx[y]);
// }
//}
//void build(int l, int r, int i)
//{
// if (l == r)
// {
// sm[i] = arr[l];
// mx[i] = arr[l];
// mxcnt[i] = 1;
// semx[i] = -1e18;
// // semxcnt[i] = 1;
// ad1[i] = 0;
// ad2[i] = 0;
// ad3[i] = 0;
// ad4[i] = 0;
// hismx[i] = arr[l];
// return;
// }
// int mid = (l + r) >> 1;
// build(l, mid, i << 1);
// build(mid + 1, r, i << 1 | 1);
// up(i);
// ad1[i] = 0;
// ad2[i] = 0;
// ad3[i] = 0;
// ad4[i] = 0;
//}
//
//void lazy(int i, int n,int v1,int v2,int v3,int v4)
//{
// hismx[i] = max({ mx[i] + v3, hismx[i]});
// ad3[i] = max(ad1[i]+v3,ad3[i]);
// ad4[i] = max(ad2[i] + v4, ad4[i]);
// sm[i] += v1 * mxcnt[i];
// sm[i] += v2 * (n-mxcnt[i]);
// mx[i] += v1;
// semx[i] += (semx[i] == -1e18) ? 0 : v2;
// ad1[i] += v1;
// ad2[i] += v2;
//}
//void down(int i, int z, int y)
//{
// int l = i << 1;
// int r = i << 1 | 1;
// int t = max(mx[l], mx[r]);
// if(mx[l]>=mx[r])
// lazy(l, z, ad1[i], ad2[i],ad3[i],ad4[i]);
// else
// lazy(l, z, ad2[i], ad2[i],ad4[i],ad4[i]);
// if (mx[r]==t)
// lazy(r, y, ad1[i], ad2[i],ad3[i],ad4[i]);
// else
// lazy(r, y, ad2[i], ad2[i],ad4[i],ad4[i]);
// ad1[i] = 0;
// ad2[i] = 0;
// ad3[i] = 0;
// ad4[i] = 0;
//}
//
//array<int, 3> que(int jl, int jr, int l, int r, int i)
//{
// if (jl <= l && r <= jr)
// {
// return { sm[i],mx[i],hismx[i] };
// }
// int mid = (l + r) >> 1;
// down(i, mid - l + 1, r - mid);
// array<int, 3>ans = { 0,(int)-1e18,(int)-1e18 };
// if (jl <= mid)
// {
// array<int, 3>a = que(jl, jr, l, mid, i << 1);
// ans[0] += a[0];
// ans[1] = max(ans[1], a[1]);
// ans[2] = max(ans[2], a[2]);
// }
// if (mid + 1 <= jr)
// {
// array<int, 3>a = que(jl, jr, mid + 1, r, i << 1 | 1);
// ans[0] += a[0];
// ans[1] = max(ans[1], a[1]);
// ans[2] = max(ans[2], a[2]);
// }
//
// return ans;
//
//}
//void update(int jl, int jr, int jv, int l, int r, int i)
//{
// if (jv >= mx[i])return;
// if (l >= jl && r <= jr&&jv>semx[i])
// {
//
// lazy(i, r - l + 1, jv - mx[i], 0ll, jv - mx[i], 0ll);
// }
// else
// {
// int mid = (l + r) >> 1;
// down(i, mid - l + 1, r - mid);
// if (jl <= mid)
// update(jl, jr, jv, l, mid, i << 1);
// if (jr >= mid + 1)
// update(jl, jr, jv, mid + 1, r, i << 1 | 1);
// up(i);
// }
//
//}
//void _add(int jl, int jr, int jv, int l, int r, int i)
//{
// if (l >= jl && r <= jr)
// {
// lazy(i, r - l + 1, jv, jv, jv, jv);
// }
// else
// {
// int mid = (l + r) >> 1;
// down(i, mid - l + 1, r - mid);
// if (jl <= mid)
// _add(jl, jr, jv, l, mid, i << 1);
// if (jr >= mid + 1)
// _add(jl, jr, jv, mid + 1, r, i << 1 | 1);
// up(i);
// }
//
//}
//int mul(int a, int b) {
// return (int)((1ll * a * b) % mod);
//}
//int binpow(int a, int pw) {
// int b = 1;
// while (pw) {
// if (pw & 1)
// b = mul(b, a);
// a = mul(a, a);
// pw >>= 1;
// }
// return b;
//}
//int inv(int a) {
// return binpow(a, mod - 2);
//}
//const int N = 1000001;
//int ff[N], rr[N];
//void precalc() {
// ff[0] = 1;
// for (int i = 1; i < N; i++)
// ff[i] = mul(ff[i - 1], i);
// rr[N - 1] = inv(ff[N - 1]);
// for (int i = N - 2; i > -1; i--)
// rr[i] = mul(rr[i + 1], i + 1);
//}
//int C(int n, int k) {
// if (n < 0 || k < 0 || n < k)
// return 0;
// return mul(ff[n], mul(rr[k], rr[n - k]));
//}
//
//int add(int a, int b) {
// if (a + b >= mod)
// return a + b - mod;
// return a + b;
//}
//int arr[100001];
//int mn[400004];
//int mx[400004];
//int sm[400004];
//int laz[400004];
//int change[400004];
//bool vis[400004];
//array<int, 3> build(int l, int r, int i)
//{
// if (l == r)
// {
// sm[i] = arr[l];
// mx[i] = arr[l];
// mn[i] = arr[l];
// laz[i] = 0;
// return{ sm[i],mx[i],mn[i] };
// }
// int mid = (l + r) >> 1;
// array<int, 3> a = build(l, mid, i << 1);
// array<int, 3> b = build(mid + 1, r, i << 1 | 1);
// sm[i] = a[0] + b[0];
// mx[i] = max(a[1], b[1]);
// mn[i] = min(a[2], b[2]);
// laz[i] = 0;
// return { sm[i],mx[i],mn[i] };
//}
//void lazy(int i, int n, int v)
//{
// if (vis[i])
// {
// sm[i] = n * change[i];
// mx[i] = change[i];
// mn[i] = change[i];
// laz[i] = change[i];
// }
// if (v != 0) {
// sm[i] += n * v;
// mx[i] += v;
// mn[i] += v;
// laz[i] += v;
// }
//}
//void down(int i, int z, int y)
//{
// if (laz[i] != 0 || vis[i])
// {
// lazy(i << 1, z, laz[i]);
// lazy(i << 1 | 1, y, laz[i]);
// }
// laz[i] = 0; vis[i] = false;
//}
//void up(int i)
//{
// sm[i] = sm[i << 1] + sm[i << 1 | 1];
// mx[i] = max(mx[i << 1], mx[i << 1 | 1]);
// mn[i] = min(mn[i << 1], mn[i << 1 | 1]);
//}
//array<int, 3> que(int jl, int jr, int l, int r, int i)
//{
// if (jl <= l && r <= jr)
// {
// return{ sm[i],mx[i],mn[i] };
// }
// int mid = (l + r) >> 1;
// down(i, mid - l + 1, r - mid);
// array<int, 3>ans = { 0,-1e18,1e18 };
// if (jl <= mid)
// {
// array<int, 3>a = que(jl, jr, l, mid, i << 1);
// ans[0] += a[0];
// ans[1] = max(a[1], ans[1]);
// ans[2] = min(a[2], ans[2]);
// }
// if (jr >= mid + 1)
// {
// array<int, 3>a = que(jl, jr, mid + 1, r, i << 1 | 1);
// ans[0] += a[0];
// ans[1] = max(a[1], ans[1]);
// ans[2] = min(a[2], ans[2]);
// }
// return ans;
//}
//void _add(int jl, int jr, int jv, int l, int r, int i)
//{
// if (l >= jl && r <= jr)
// {
// lazy(i, r - l + 1, jv);
// }
// else
// {
// int mid = (l + r) >> 1;
// down(i, mid - l + 1, r - mid);
// if (jl <= mid)
// _add(jl, jr, jv, l, mid, i << 1);
// if (jr >= mid + 1)
// _add(jl, jr, jv, mid + 1, r, i << 1 | 1);
// up(i);
// }
//}void update(int jl, int jr, int jv, int l, int r, int i)
//{
// if (l >= jl && r <= jr)
// {
// change[i] = jv;
// vis[i] = true;
// laz[i] = 0;
// lazy(i, r - l + 1, laz[i]);
// }
// else
// {
// int mid = (l + r) >> 1;
// down(i, mid - l + 1, r - mid);
// if (jl <= mid)
// update(jl, jr, jv, l, mid, i << 1);
// if (jr >= mid + 1)
// update(jl, jr, jv, mid + 1, r, i << 1 | 1);
// up(i);
// }
//}
//int mul(int a, int b) {
// return (int)((1ll * a * b) % mod);
// }
// int binpow(int a, int pw) {
// int b = 1;
// while (pw) {
// if (pw & 1)
// b = mul(b, a);
// a = mul(a, a);
// pw >>= 1;
// }
// return b;
// }
// int inv(int a) {
// return binpow(a, mod - 2);
// }
// const int N = 100001;
// int ff[N], rr[N];
// void precalc() {
// ff[0] = 1;
// for (int i = 1; i < N; i++)
// ff[i] = mul(ff[i - 1], i);
// rr[N - 1] = inv(ff[N - 1]);
// for (int i = N - 2; i > -1; i--)
// rr[i] = mul(rr[i + 1], i + 1);
// }
// int C(int n, int k) {
// if (n < 0 || k < 0 || n < k)
// return 0;
// return mul(ff[n], mul(rr[k], rr[n - k]));
// }
//
// int add(int a, int b) {
// if (a + b >= mod)
// return a + b - mod;
// return a + b;
// }
//namespace string_hash
//{#define LL long long
// const int N = 1e6 + 20;
// const int mod1 = 998244353;
// const int mod2 = 1e9 + 7;
// const int P = 1000007;
// LL p1[N], p2[N];
// // 双模数初始化
// void mod_init()
// {
// p1[0] = p2[0] = 1;
// for (int i = 1; i < N; i++)
// {
// p1[i] = p1[i - 1] * P % mod1;
// p2[i] = p2[i - 1] * P % mod2;
// }
// }
// struct Hash_String
// {
// string str;
// int string_size;
// vector<LL> h1, h2;
// Hash_String(string s) : str(s), h1(s.size() + 1), h2(s.size() + 1)
// {
// str = ' ' + str;
// string_size = str.size() - 1;
// for (int i = 1; i < str.size(); i++)
// {
// h1[i] = (h1[i - 1] * P + str[i]) % mod1;
// h2[i] = (h2[i - 1] * P + str[i]) % mod2;
// }
// }
// pair<LL, LL> get(int l, int r)
// {
// if (l > r)
// return { 0, 0 };
// // assert(l <= r && l >= 1 && r <= string_size);
// LL res1 = ((h1[r] - h1[l - 1] * p1[r - l + 1] % mod1) % mod1 + mod1) % mod1;
// LL res2 = ((h2[r] - h2[l - 1] * p2[r - l + 1] % mod2) % mod2 + mod2) % mod2;
// return { res1, res2 };
// }
// ll oneget(int l, int r) // 用于没办法用pair,只能用一个整数,但是单hash又会错的情况
// {
// if (l > r)
// return 0;
// LL res1 = ((h1[r] - h1[l - 1] * p1[r - l + 1] % mod1) % mod1 + mod1) % mod1;
// LL res2 = ((h2[r] - h2[l - 1] * p2[r - l + 1] % mod2) % mod2 + mod2) % mod2;
// return (res1 + P * res2);
// }
// pair<LL, LL> get_substring(int l1, int r1, int l2, int r2)
// {
// auto [v1, v2] = get(l1, r1);
// auto [vv1, vv2] = get(l2, r2);
// return make_pair((v1 * p1[r2 - l2 + 1] % mod1 + vv1) % mod1, (v2 * p2[r2 - l2 + 1] % mod2 + vv2) % mod2);
// // get_hash(l1, r1) * p[r2 - l2 + 1] + get_hash(l2, r2)
// }
// };
//};
//using namespace string_hash;
// int arr[100001];
//int sm1[400004];
//int sm0[400004];
//int mx1[400004];
//int mx0[400004];
//int pre1[4000004];
//int suf1[4000004];
//int pre0[4000004];
//int suf0[4000004];
//bool revers[400004];
//int change[400004];
//bool vis[400004];
//void up(int i, int l, int r)
//{
// int mid = (l + r) >> 1;
// sm1[i] = sm1[i << 1] + sm1[i << 1 | 1];
// sm0[i] = sm0[i << 1] + sm0[i << 1 | 1];
// mx1[i] = max({ mx1[i << 1],mx1[i << 1 | 1] ,suf1[i << 1] + pre1[i << 1 | 1] });
// mx0[i] = max({ mx0[i << 1], mx0[i << 1 | 1] ,suf0[i << 1] + pre0[i << 1 | 1] });
// if (pre1[i << 1] == mid - l + 1)
// pre1[i] = pre1[i << 1] + pre1[i << 1 | 1];
// else pre1[i] = pre1[i << 1];
// if (pre0[i << 1] == mid - l + 1)
// pre0[i] = pre0[i << 1] + pre0[i << 1 | 1];
// else pre0[i] = pre0[i << 1];
// if (suf1[i << 1 | 1] == r - mid)
// suf1[i] = suf1[i << 1 | 1] + suf1[i << 1];
// else suf1[i] = suf1[i << 1 | 1];
// if (suf0[i << 1 | 1] == r - mid)
// suf0[i] = suf0[i << 1 | 1] + suf0[i << 1];
// else suf0[i] = suf0[i << 1 | 1];
//}
//void build(int l, int r, int i)
//{
// if (l == r)
// {
// sm1[i] = arr[l];
// sm0[i] = 1-arr[l];
// mx1[i] = sm1[i];
// mx0[i] = sm0[i];
// pre1[i] = sm1[i];
// pre0[i] = sm0[i];
// suf1[i] = sm1[i];
// suf0[i] = sm0[i];
// vis[i] = false;
// revers[i] = false;
// change[i] = 0;
// //return{ sm1[i],sm0[i],mx1[i],mx0[i],pre1[i],pre0[i],suf1[i],suf0[i] };
// return;
// }
// int mid = (l + r) >> 1;
// build(l, mid, i << 1);
// build(mid + 1, r, i << 1 | 1);
// up(i, l, r);
// vis[i] = false;
// revers[i] = false;
// change[i] = 0;
// //return{ sm1[i],sm0[i],mx1[i],mx0[i],pre1[i],pre0[i],suf1[i],suf0[i] };
//}
//void ulazy(int i, int n,int v)
//{
// if (v == 1) {
// sm1[i] = n;
// sm0[i] = 0;
// mx1[i] = n;
// mx0[i] = 0;
// pre1[i] = n;
// pre0[i] = 0;
// suf1[i] = n;
// suf0[i] = 0;
// }
// else
// {
// sm1[i] = 0;
// sm0[i] = n;
// mx1[i] = 0;
// mx0[i] = n;
// pre1[i] = 0;
// pre0[i] = n;
// suf1[i] = 0;
// suf0[i] = n;
// }
// change[i] = v;
// vis[i] = true;
// revers[i] = false;
//}
//void rlazy(int i, int n)
//{
// swap(sm1[i], sm0[i]);
// swap(mx1[i], mx0[i]);
// swap(pre1[i], pre0[i]);
// swap(suf1[i], suf0[i]);
// revers[i] = !revers[i];
//}
//void down(int i, int z, int y)
//{
// if (vis[i])
// {
// ulazy(i << 1, z,change[i]);
// ulazy(i << 1 | 1, y,change[i]);
// vis[i] = false;
// }
// if (revers[i])
// {
// rlazy(i << 1, z);
// rlazy(i << 1 | 1, y);
// revers[i] = false;
// }
//}
//int ques(int jl, int jr, int l, int r, int i)
//{
// if (jl <= l && r <= jr)
// {
// return sm1[i];
// }
// int mid = (l + r) >> 1;
// int ans = 0;
// down(i, mid - l + 1, r - mid);
// //array<int, 4>ans = { 0,-1e18,0,0 };
// if (jl <= mid)
// {
// ans+= ques(jl, jr, l, mid, i << 1);
//
// }
// if (mid + 1 <= jr)
// {
// ans+= ques(jl, jr, mid + 1, r, i << 1 | 1);
//
// }
// return ans;
//
//}
//array<int, 4> que(int jl, int jr, int l, int r, int i)
//{
// if (jl <= l && r <= jr)
// {
// return{ sm1[i],mx1[i],pre1[i],suf1[i] };
// }
// int mid = (l + r) >> 1;
// down(i, mid - l + 1, r - mid);
// //array<int, 4>ans = { 0,-1e18,0,0 };
// if (jr <= mid)
// {
// return que(jl, jr, l, mid, i << 1);
//
// }
// if ( mid + 1<=jl)
// {
// return que(jl, jr, mid + 1, r, i << 1 | 1);
//
// }
// array<int, 4>a = que(jl, jr, l, mid, i<<1);
// array<int, 4>b = que(jl, jr, mid + 1, r, i<<1|1);
// int z = 0, zz = 0;
// if (a[2] == mid - max(jl,l) + 1)z = a[2] + b[2];
// else z = a[2];
// if (b[3] == min(jr,r) - mid)zz = b[3] + a[3];
// else zz = b[3];
// return{ a[0] + b[0],max({a[1],b[1],a[3] + b[2]}),z,zz };
//
//}
//void _reverse(int jl, int jr, int l, int r, int i)
//{
// if (l >= jl && r <= jr)
// {
// rlazy(i, r - l + 1);
// }
// else
// {
// int mid = (l + r) >> 1;
// down(i, mid - l + 1, r - mid);
// if (jl <= mid)
// _reverse(jl, jr, l, mid, i << 1);
// if (jr >= mid + 1)
// _reverse(jl, jr, mid + 1, r, i << 1 | 1);
// up(i,l,r);
// }
//}void update(int jl, int jr, int jv, int l, int r, int i)
//{
// if (l >= jl && r <= jr)
// {
//
// ulazy(i, r - l + 1,jv);
// }
// else
// {
// int mid = (l + r) >> 1;
// down(i, mid - l + 1, r - mid);
// if (jl <= mid)
// update(jl, jr, jv, l, mid, i << 1);
// if (jr >= mid + 1)
// update(jl, jr, jv, mid + 1, r, i << 1 | 1);
// up(i,l,r);
// }
//}
//const int NN = 2049;
//int tree1[NN][NN];
//int tree2[NN][NN];
//int tree3[NN][NN];
//int tree4[NN][NN];
//int n, m;
////int lowbit(int i)
////{
//// return(i & -i);
////}
//void add1(int x, int y, int v)
//{
// int v1 = v;
// int v2 = v * x;
// int v3 = v * y;
// int v4 = x * y * v;
// for (int i = x; i <= n; i += (lowbit(i)))
// {
// for (int j = y; j <= m; j += lowbit(j))
// {
// tree1[i][j] += v1;
// tree2[i][j] += v2;
// tree3[i][j] += v3;
// tree4[i][j] += v4;
// }
// }
//}
//void add1(int a, int b, int c, int d,int v)
//{
// add1(a, b, v);
// add1(c+1, b, -v);
// add1(a, d+1, -v);
// add1(c+1, d+1, v);
//}
//int query1(int x, int y)
//{
// int ans = 0;
// for (int i = x; i > 0; i -= lowbit(i))
// {
// for (int j = y; j > 0; j -= lowbit(j))
// {
// ans += ((x+1)*(y+1)*tree1[i][j]);
// ans -= ((y+1)*tree2[i][j]);
// ans -= ((x+1)*tree3[i][j]);
// ans += tree4[i][j];
// }
// }
// return ans;
//}
//int query(int a, int b, int c, int d)
//{
// return query1(a-1, b-1) + query1(c, d) - query1(a - 1, d) - query1(c, b - 1);
//}
/* int tree1[114514];
int tree2[114514];
int n;
void add1(int* tree,int i, int v)
{
while (i <= n)
{
tree[i] += v;
i += (i & -i);
}
}
void add12(int l, int r, int v)
{
add1(tree1,l, v);
add1(tree1,r+1, -v);
add1(tree2,l, (l - 1) * v);
add1(tree2,r+1, -(r * v));
}
int query1(int * tree,int i)
{
int ans = 0;
while (i)
{
ans += tree[i];
i -= (i & -i);
}
return ans;
}
int query(int l,int r)
{
return r * query1(tree1, r) - query1(tree2, r) - (l - 1) * query1(tree1, l - 1) + query1(tree2, l - 1);
}*/
/* auto adj = [&]() {//set维护中位数板子
if (ma.size() >= mi.size() + 3)
{
auto a = ma.begin();
suma += *a;
sumb -= *a;
mi.insert(*a);
ma.erase(a);
}
if (ma.size() > mi.size())return;
auto a = --mi.end();
suma -= *a;
sumb += *a;
ma.insert(*a);
mi.erase(a);
};*/
// int wwr[1001];
//int find(int x)
//{
// if (x != wwr[x])
// {
// int w = find(wwr[x]);
// wwr[x] = w;
// return w;
// }
// else
// {
// return x;
// }
//}
//void wbwb(int a, int b)
//{
// int fa = find(a);
// int fb = find(b);
// if (fa != fb)
// {
// wwr[fa] = fb;
// // cnt[fb] += cnt[fa];
// }
//}
//int prime[1000010] = { 0 };//质数
//int minp[1000010] = { 0 };//最小质因子
//void olshai(int n)
//{
// int cnt = 0;
// for (int i = 2; i <= n; i++)
// {
// if (minp[i] == 0) { minp[i] = i; prime[++cnt] = i; }
// for (int j = 1; j <= cnt; j++) { if (prime[j] > minp[i] || prime[j] > n / i) break; minp[i * prime[j]] = prime[j]; }
// }
//
//}
/* auto dij = [&](int s, int d[], bool vis[]) {
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
for (int i = 0; i <= 1 * n; i++)
d[i] = 1e18, vis[i] = 0;
d[s] = 0;
q.push({ 0,s });
while (q.size()) {
auto t = q.top();
q.pop();
int u = t.second;
if (vis[u]) continue;
vis[u] = true;
for (auto ed : arr[u]) {
int v = ed.first, w = ed.second;
if (d[v] > d[u] + w) {
d[v] = d[u] + w;
q.push({ d[v],v });
}
}
}
};*/
/* int mergesort(vector<int>& nums, int l, int r)
{
long long ret = 0;
if (l >= r)
return 0;
int mid = (l + r) >> 1;
ret = (ret + mergesort(nums, l, mid)) % mod;
ret = (ret + mergesort(nums, mid + 1, r)) % mod;
int cur1 = l, cur2 = mid + 1, i = l;
while (cur1 <= mid && cur2 <= r)
{
if (nums[cur1] <= nums[cur2])
{
tem[i++] = nums[cur1++];
}
else {
ret = ((ret + mid) % mod - cur1 + 1) % mod;
tem[i++] = nums[cur2++];
}
}
while (cur1 <= mid)tem[i++] = nums[cur1++];
while (cur2 <= r)tem[i++] = nums[cur2++];
for (int i = l; i <= r; i++)
nums[i] = tem[i];
return ret % mod;
}*/
//int InversePairs(vector<int>& nums) {
// tem.resize(nums.size());
// return mergesort(nums, 0, nums.size() - 1) % mod;
//}
//多重背包模板
// int n, m;
//int a[101];
//int b[101];
//int c[101];
//int dp[40000 + 1];
//int que[50000 + 100000 + 1]; cin >> n >> m;
//for1
//{
// cin >> a[i] >> b[i] >> c[i];
//}
//
//for1
//{
//
//
//for (int md = 0; md <= min(m , b[i] - 1); md++)
//{
// int l = 0, r = 0;
//
// for (int j = m - md,k = 0; j >= 0 && k <= c[i]; j -= b[i],k++)
// {
// while (l < r && dp[que[r - 1]] <= dp[j] + a[i] * ((que[r - 1] - j) / b[i]))
// {
// r--;
// }
// que[r++] = j;
//
// }
// for (int j = m - md; j >= 0; j -= b[i])
// {
//
// dp[j] = dp[que[l]] + a[i] * ((j - que[l]) / b[i]);
// if (j == que[l])l++;
// int wwr = j - b[i] * (c[i] + 1);
// if (wwr >= 0)
// {
// while (l < r && dp[que[r - 1]] <= dp[wwr] + a[i] * ((que[r - 1] - wwr) / b[i]))
// r--;
// que[r++] = wwr;
// }
// }
//}
//
//}
//cout << dp[m] << endl;..
// vector :c.assign(beg, end) 将另外一个容器[x.begin(), x.end()) 里的内容拷贝到c中
//vector<int>::iterator it;
// 相当于声明了一个迭代器类型的变量it
//less<int> 表示数字大的优先级大,堆顶为最大的数字
//greater<int>表示数字小的优先级大,堆顶为最小的数字,优先队列比较要写结构体cmp
//mp.lower_bound() 返回一个迭代器,指向键值 >= key的第一个元素
//mp.upper_bound() 返回一个迭代器,指向键值 > key的第一个元素 for(auto [x, y] : mp)
//getline(cin, s)会获取前一个输入的换行符,需要在前面添加读取换行符的语句。如:getchar() 或 cin.get()
//tolower(s[i]) 转换为小写
//toupper(s[i]) 转换为大写
//transform(s.begin(), s.end(), s.begin(), ::tolower);//转换小写
//transform(s.begin(), s.end(), s.begin(), ::toupper);//转换大写 find返回-1是找不到
//bitset<n> a(s) a是string对象s中含有的位串的副本
//bitset<n> a(s, pos, n) a是s中从位置pos开始的n个位的副本 bitset可以进行位操作可以通过 [] 访问元素
//b.count() b中为1的个数
//fill(a.begin(), a.end(), x)填充
//tuple获取对应元素的值通过get<n>(tuple)方法获取, n必须为数字不能是变量
//tie可以让tuple变量中的三个值依次赋到tie中的三个变量中tie(one, two, three) = t;
//accumulate(beg, end, init)作用:对一个序列的元素求和init为对序列元素求和的初始值返回值类型:与init 相同
//atoi(const char*)将字符串转换为int类型int a = atoi(s.c_str());
//is_sorted(beg, end) 判断序列是否有序(升序),返回bool值
//iota(beg, end,初始值)让序列递增赋值如 把数组赋值为:0 1 2 3 4 5
//max_element+min_element找最大最小值
////找到a,b,c,d的最大值和最小值
//mx = max({ a, b, c, d });
//mn = min({ a, b, c, d });
//nth_element(beg, nth, end)复杂度: 平均O(N)O(N)寻找第序列第n小的值
//shuffle(b.begin(), b.end()); 随机打乱序列的顺序
//reverse(beg, end)对序列进行翻转
//stable_sort区别在于stable_sort()能够保证相等元素的相对位置,排序时不会改变相等元素的相对位置
//unique(beg, end)消除重复元素,返回消除完重复元素的下一个位置的地址
// 消除重复元素一般需要原序列是有序序列 unique 之后 a 数组为 { 1, 2, 3, 6, 3 }前面为无重复元素的数组,后面则是重复元素移到后面,返回a[4]
//int len = unique(b, b + n) - b;//消除 b 的重复元素,并获取长度
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 5740kb
input:
6 20 3 8 12 6 9 9
output:
0 8 -1 4 13 14
result:
ok 6 lines
Test #2:
score: 0
Accepted
time: 50ms
memory: 25020kb
input:
500000 1000000000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...
result:
ok 500000 lines
Test #3:
score: 0
Accepted
time: 52ms
memory: 24912kb
input:
500000 10000000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...
result:
ok 500000 lines
Test #4:
score: 0
Accepted
time: 50ms
memory: 24928kb
input:
500000 1000000000 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ...
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...
result:
ok 500000 lines
Test #5:
score: 0
Accepted
time: 57ms
memory: 24928kb
input:
500000 1000000000 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 ...
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...
result:
ok 500000 lines
Test #6:
score: 0
Accepted
time: 53ms
memory: 24956kb
input:
500000 1000000000 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 ...
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...
result:
ok 500000 lines
Test #7:
score: 0
Accepted
time: 40ms
memory: 24792kb
input:
500000 1000000000 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 ...
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...
result:
ok 500000 lines
Test #8:
score: 0
Accepted
time: 52ms
memory: 24840kb
input:
500000 1000000000 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 ...
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...
result:
ok 500000 lines
Test #9:
score: 0
Accepted
time: 54ms
memory: 24976kb
input:
500000 1000000000 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 ...
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...
result:
ok 500000 lines
Test #10:
score: 0
Accepted
time: 36ms
memory: 16932kb
input:
300000 200000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...
result:
ok 300000 lines
Test #11:
score: 0
Accepted
time: 29ms
memory: 17040kb
input:
300000 200000 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ...
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...
result:
ok 300000 lines
Test #12:
score: 0
Accepted
time: 36ms
memory: 17016kb
input:
300000 1000000000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...
result:
ok 300000 lines
Test #13:
score: 0
Accepted
time: 1ms
memory: 5692kb
input:
100 1000000000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
result:
ok 100 lines
Test #14:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
100 10 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
output:
0 1 2 3 4 5 6 7 8 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
result:
ok 100 lines
Test #15:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
5 1000000000 114514 1919810 42 188888888 987654321
output:
114472 3725065 0 564632301 -1
result:
ok 5 lines
Test #16:
score: 0
Accepted
time: 1ms
memory: 5888kb
input:
2 1000000000 1000000000 1
output:
-1 0
result:
ok 2 lines
Test #17:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
70 1000000000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
result:
ok 70 lines
Test #18:
score: 0
Accepted
time: 1ms
memory: 5752kb
input:
10 10 1 1 1 1 1 1 1 1 1 1
output:
0 1 2 3 4 5 6 7 8 -1
result:
ok 10 lines
Test #19:
score: 0
Accepted
time: 50ms
memory: 24772kb
input:
500000 1000000000 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ...
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...
result:
ok 500000 lines
Test #20:
score: 0
Accepted
time: 18ms
memory: 13088kb
input:
200000 1000000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...
result:
ok 200000 lines
Test #21:
score: 0
Accepted
time: 24ms
memory: 11140kb
input:
200000 1000000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...
result:
ok 200000 lines
Test #22:
score: 0
Accepted
time: 42ms
memory: 25024kb
input:
500000 10000 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3...
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...
result:
ok 500000 lines
Test #23:
score: 0
Accepted
time: 1ms
memory: 5708kb
input:
50 1000000000 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
result:
ok 50 lines
Test #24:
score: 0
Accepted
time: 44ms
memory: 20780kb
input:
400000 1000000000 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ...
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...
result:
ok 400000 lines
Test #25:
score: 0
Accepted
time: 44ms
memory: 20940kb
input:
400000 200000 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...
result:
ok 400000 lines
Test #26:
score: 0
Accepted
time: 358ms
memory: 79232kb
input:
500000 1000000000 998524640 998571529 998454399 998672383 998672780 998505456 998528789 998304951 998394266 998666568 998435296 998244658 998486721 998408564 998281668 998344975 998602953 998355446 998505615 998560074 998649209 998662668 998411769 998619635 998542652 998506747 998540826 998333379 99...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 46665 -1 -1 696223271 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 713192030 -1 18069067 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 9903476 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 12497502 -1 -1 -1 -1 -1...
result:
ok 500000 lines
Test #27:
score: 0
Accepted
time: 204ms
memory: 32952kb
input:
500000 1000000000 934281838 934263192 934287286 934239743 934243765 934262733 934291992 934256023 934265169 934258780 934246083 934251685 934273017 934274158 934264586 934284605 934285579 934244407 934281377 934266910 934249796 934277949 934295862 934242028 934266412 934259441 934247122 934256482 93...
output:
-1 -1 -1 106241065 317973223 -1 -1 -1 -1 -1 491437277 -1 -1 -1 -1 -1 -1 362250359 -1 -1 847669925 -1 -1 212639806 -1 -1 581397017 -1 -1 -1 -1 -1 -1 -1 286310432 542465181 -1 -1 59395980 82467 -1 -1 335968527 761678 -1 -1 -1 -1 -1 -1 -1 -1 -1 927691393 -1 -1 -1 -1 -1 542813828 -1 -1 -1 -1 103064160 3...
result:
ok 500000 lines
Test #28:
score: 0
Accepted
time: 156ms
memory: 25976kb
input:
500000 1000000000 999343307 999347629 999343355 999343249 999346214 999343949 999345974 999346616 999343167 999343390 999348863 999345664 999347085 999350711 999343996 999348680 999346311 999346834 999344902 999341562 999348239 999347549 999345200 999347878 999349864 999346595 999346033 999344493 99...
output:
106967300 -1 111989301 101052750 618890003 183670253 560624004 722937656 92977800 115723804 -1 489626256 854539060 -1 190095156 -1 643256410 782740512 335530807 2616300 -1 995560266 392337059 -1 -1 717302314 574680762 264794258 176159256 -1 355793911 542307664 30003001 -1 -1 -1 1316750 391545164 -1 ...
result:
ok 500000 lines
Test #29:
score: 0
Accepted
time: 144ms
memory: 25248kb
input:
499999 1000000000 233333727 233334298 233334567 233334159 233334472 233333598 233334091 233334417 233333514 233334338 233333581 233333539 233334545 233334277 233333921 233333497 233334717 233333590 233333805 233334098 233333949 233333556 233333748 233333476 233334069 233334528 233333484 233334046 23...
output:
27235250 163133251 266698252 119542851 227230503 12335750 100681352 205824505 5764850 176930256 10806601 7462351 257277311 156114007 60608105 4735500 335447016 11603554 39069807 102548260 66512609 8741603 30212008 3603600 94925613 250113522 4016601 89089364 154136869 8741606 7607605 81039016 2389276...
result:
ok 499999 lines
Test #30:
score: 0
Accepted
time: 115ms
memory: 24900kb
input:
500000 1000000000 5 53 183 112 47 158 114 200 43 127 191 93 93 1 176 148 92 130 121 165 5 29 147 135 120 27 87 56 193 82 61 145 17 72 63 162 175 58 7 50 112 179 57 136 123 88 182 150 94 143 96 32 195 107 58 130 24 89 152 5 107 168 172 73 200 185 200 155 6 160 189 162 86 82 34 169 66 94 28 17 198 110...
output:
25000 3445001 41632502 15540002 2702501 31007504 16102504 49750007 2257501 20002506 45362509 10695004 10695005 0 38500011 27195010 10465005 20962511 18150010 33825015 25002 1015003 26827515 22612515 17850012 877503 9352508 3850008 46320027 8302509 4575009 26100022 340003 6390011 4882511 32602529 380...
result:
ok 500000 lines
Test #31:
score: 0
Accepted
time: 116ms
memory: 24952kb
input:
500000 1000000000 987654346 987654322 987654326 987654328 987654336 987654325 987654338 987654346 987654347 987654340 987654335 987654346 987654337 987654334 987654329 987654331 987654328 987654341 987654346 987654328 987654348 987654332 987654333 987654338 987654349 987654331 987654321 987654334 98...
output:
5687500 17500 262501 490002 2100003 175001 2677505 5687507 6142508 3325006 1837504 5687510 2380006 1592504 630004 962505 490004 3675013 5687517 490005 6615020 1155008 1365009 2677515 7105024 962508 0 1592513 3675021 1155011 17502 3675024 2100018 17503 1 2100021 5687533 787511 4830030 3325027 105005 ...
result:
ok 500000 lines
Test #32:
score: 0
Accepted
time: 105ms
memory: 24756kb
input:
500000 1000000000 999999925 999999925 999999924 999999923 999999924 999999925 999999925 999999926 999999925 999999925 999999923 999999925 999999926 999999926 999999923 999999923 999999923 999999923 999999924 999999926 999999926 999999925 999999923 999999924 999999924 999999923 999999923 999999923 99...
output:
375000 375001 125000 0 125002 375005 375006 750007 375007 375008 1 375010 750012 750013 2 3 4 5 125008 750019 750020 375016 6 125010 125011 7 8 9 10 375024 11 125017 12 375028 375029 750035 750036 375030 125019 750039 375032 125020 125021 375035 375036 750045 13 375038 750048 750049 125023 125024 14...
result:
ok 500000 lines
Test #33:
score: 0
Accepted
time: 105ms
memory: 25020kb
input:
500000 1000000000 754193961 754193961 754193962 754193961 754193961 754193961 754193962 754193961 754193961 754193961 754193962 754193961 754193961 754193961 754193961 754193961 754193961 754193961 754193961 754193961 754193962 754193962 754193961 754193962 754193962 754193961 754193961 754193961 75...
output:
0 1 250002 2 3 4 250006 5 6 7 250010 8 9 10 11 12 13 14 15 16 250020 250021 17 250023 250024 18 19 20 250028 21 250030 250031 250032 250033 250034 250035 250036 250037 250038 250039 22 23 250042 250043 250044 250045 250046 24 250048 250049 250050 250051 25 26 250054 27 28 250057 29 30 250060 250061 ...
result:
ok 500000 lines
Test #34:
score: 0
Accepted
time: 57ms
memory: 24840kb
input:
500000 1000000000 338919691 338919691 338919691 338919691 338919691 338919691 338919691 338919691 338919691 338919691 338919691 338919691 338919691 338919691 338919691 338919691 338919691 338919691 338919691 338919691 338919691 338919691 338919691 338919691 338919691 338919691 338919691 338919691 33...
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...
result:
ok 500000 lines
Test #35:
score: 0
Accepted
time: 0ms
memory: 5960kb
input:
10 1000000000 945194997 993149307 561560517 986298691 890390071 998287269 780780220 972597460 996574615 123121111
output:
-1 -1 438439406 -1 -1 -1 876878813 -1 -1 0
result:
ok 10 lines
Test #36:
score: 0
Accepted
time: 1ms
memory: 5832kb
input:
20 1000000000 971326041 999426470 999405884 943218749 992406510 887004166 999213744 997676627 999378435 998994156 995919921 549716666 985379687 100000000 774574999 999323538 999429901 999431617 999419608 998554980
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 449716666 -1 0 899433334 -1 -1 -1 -1 -1
result:
ok 20 lines
Test #37:
score: 0
Accepted
time: 1ms
memory: 5820kb
input:
40 1000000000 188015433 462940501 462939977 462940501 462806261 462940493 462940501 458644797 462923721 462940501 462936306 462940500 461866575 462940501 454349093 462939453 428574868 394209234 462932111 462906941 462940501 462940436 445757685 462940485 462940499 462940501 462873381 462940469 462940...
output:
0 549850128 549839127 549850130 548105013 549849915 549850133 515484503 549581655 549850136 549774626 549850105 539110876 549850140 489710279 549829177 378021971 274925069 549707510 549346739 549850147 549848582 446753241 549849727 549850087 549850152 548910460 549849344 549850035 543943548 54985015...
result:
ok 40 lines
Test #38:
score: 0
Accepted
time: 0ms
memory: 5896kb
input:
80 1000000000 999999999 999999999 993133767 999999999 999999999 999999999 890140277 972535069 999999999 986267534 999999999 999999999 999999999 999999161 999999999 999999999 999999993 999999999 999998323 560561111 999785430 999999999 999141720 999999999 999999999 999999999 999999999 999999998 999946...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 439438889 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 878877779 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
result:
ok 80 lines
Extra Test:
score: 0
Extra Test Passed