QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#905027 | #7744. Elevator | LFL | WA | 0ms | 5732kb | C++14 | 783b | 2025-02-18 20:46:07 | 2025-02-18 20:46:09 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
const int MAXN = 2e5 + 5;
int T, n, m, a[MAXN], c[2][MAXN], ans[MAXN];
int lowbit(int x){ return -x & x; }
void add(int x){
int num = x;
for(; x < MAXN; x += lowbit(x)) c[0][x]++, c[1][x] += num;
}
int query(int x, bool op){
int res = 0;
for(; x; x -= lowbit(x)) res += c[op][x];
return res;
}
signed main(){
IOS;
cin >> n >> m;
for(int i = 1; i <= n; i++) cin >> a[i];
for(int i = 1; i <= n; i++)
ans[i] = query(a[i], 0), add(a[i]);
for(int i = 1; i <= n; i++)
ans[i] += query(a[i], 0) * a[i] - query(a[i], 1);
for(int i = 1; i <= n; i++) cout << (ans[i] > m - 2 ? -1 : ans[i]) << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 5732kb
input:
2 4 6 1 1 8 7 2 5 1 1 7 3 2 6 8 1200000 100000 1 100000 100000 1 12345 100000 2 100000 100000 2 12345 100000 1 100000 100000 1 12345 100000 2 100000 100000 2 12345
output:
-1 0
result:
wrong answer 1st lines differ - expected: '24', found: '-1'