QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#96460 | #5159. Justice Served | nondeterministic# | WA | 134ms | 10928kb | C++14 | 1.7kb | 2023-04-13 21:44:04 | 2023-04-13 21:45:21 |
Judging History
answer
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T> using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
const int N = 2e5 + 5, MOD = 998244353;
const ld PI = acos(-1);
char grid[705][705];
int h, w;
vector<pair<int, int>> v;
bool cmp(int i, int j) {
if (v[i].first == v[j].first)
return v[i].second > v[j].second;
return v[i].first < v[j].first;
}
void doWork() {
int n;
cin >> n;
v.resize(n);
vector<int> ans(n);
vector<int> ind(n);
iota(ind.begin(), ind.end(), 0);
ordered_multiset<int>st;
for (int i = 0; i < n; i++) {
cin >> v[i].first >> v[i].second;
v[i].second += v[i].first;
}
sort(ind.begin(), ind.end(), cmp);
for(int i=0;i<n;i++)
{
ans[ind[i]] = (int)st.size() - st.order_of_key(v[ind[i]].second-1);
st.insert(v[ind[i]].second);
if(st.order_of_key(v[ind[i]].second) > 0)
{
auto it = st.upper_bound(v[ind[i]].second);
it--;
st.erase(it);
}
// for(auto j : st)
// cout<<j<<' ';
// cout<<endl;
}
for(int i=0;i<n;i++)
cout<<ans[i]<<' ';
cout<<endl;
}
int main() {
IO
int T = 1;
//cin >> T;
while (T--) {
doWork();
}
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3476kb
input:
4 2 8 1 7 4 5 5 2
output:
0 0 1 2
result:
ok single line: '0 0 1 2 '
Test #2:
score: 0
Accepted
time: 2ms
memory: 3392kb
input:
5 2 4 3 3 2 2 4 2 4 1
output:
0 1 1 2 3
result:
ok single line: '0 1 1 2 3 '
Test #3:
score: -100
Wrong Answer
time: 134ms
memory: 10928kb
input:
200000 75760147 173015388 62879760 211229046 6728658 106668560 29476341 129401393 30531505 130450085 39792769 139780734 59486082 221617335 12447225 112582555 94207716 117434450 68962063 193352291 13519090 113644734 60611935 218232526 77901558 166662816 40316254 140281744 39094390 138994435 49921965 ...
output:
51062 25770 5 10 10 12 19010 7 88301 37698 7 21153 55418 12 11 11 10 24874 11 7 8 45763 24219 12 9 55419 8 4 12678 12 65162 11 1 33102 12 20822 81107 8 1958 98787 89734 10 95816 44261 89321 10 7 12 4 8126 16028 8 8 90492 70192 36706 8 10 46831 39832 38636 9 53669 7 12 4 12 12 10 83777 15930 8 4 8 46...
result:
wrong answer 1st lines differ - expected: '51062 25770 5 10 10 12 19010 7...59 9 12 84254 91909 88054 9 7 7', found: '51062 25770 5 10 10 12 19010 7...9 9 12 84254 91909 88054 9 7 7 '