QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#511374 | #5449. 楼梯 | ewrilan# | 0 | 7ms | 5744kb | C++20 | 4.7kb | 2024-08-09 19:57:41 | 2024-08-09 19:57:42 |
answer
//
#ifndef __SIZEOF_INT128__
#define __SIZEOF_INT128__
#endif
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
template <typename T> using oset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define rep(i, p, k) for(int i(p); i < (k); ++i)
#define per(i, p, k) for(int i(p); i > (k); --i)
#define sz(x) (int)(x).size()
#define sc static_cast
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef __int128_t lll;
//#define int ll
template <typename T = int> using par = std::pair <T, T>;
#define fi first
#define se second
#define test int _number_of_tests(in()); while(_number_of_tests--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb emplace_back
struct Timer {
string name{""};
time_point<high_resolution_clock> end, start{high_resolution_clock::now()};
duration<float, std::milli> dur;
Timer() = default;
Timer(string nm): name(nm) {}
~Timer() {
end = high_resolution_clock::now(); dur= end - start;
cout << "@" << name << "> " << dur.count() << " ms" << '\n';
}
};
template <typename T = int> inline T in()
{
static T x;
std::cin >> x;
return x;
}
std::string yn(bool b)
{
if(b) return "YES\n";
else return "NO\n";
}
template <typename F, typename S> std::ostream& operator<<(std::ostream& out, const std::pair <F, S>& par);
template <typename T> std::ostream& operator<< (std::ostream& out, const std::vector <T>& wek)
{
for(const auto& i : wek)out << i << ' ';
return out;
}
template <typename F, typename S> std::ostream& operator<<(std::ostream& out, const std::pair <F, S>& par)
{
out << '{'<<par.first<<", "<<par.second<<"}";
return out;
}
#define show(x) cerr << #x << " = " << x << '\n';
std::int32_t main()
{
std::cout.tie(nullptr); //for luck
std::cin.tie(nullptr); std::ios_base::sync_with_stdio(0);
int m(in());
if(1 || m <= 1000)
{
map <int, ll> ar;
stack <pair <int, int>> dd;
int a, b;
rep(i, 0, m){
ar[0] = 0;
switch(in<char>())
{
case '+':
cin >> a >> b;
ar[a] += b;
dd.push({a, b});
break;
case 'R':
cin >> a;
rep(j, 0, a){
auto [a, b] = dd.top(); dd.pop();
if(a == -1)continue;
ar[a] -= b;
if(!ar[a])ar.erase(a);
}
break;
case '-':
while(sz(dd))dd.pop();
cin >> a >> b;
ar[a-1] += b;
while(b){
if(ar.rbegin()->second > b){
ar.rbegin()->second -= b;
b = 0;
}
else{
b -= ar.rbegin()->second;
ar.erase(prev(ar.end()));
}
}
break;
case '?':
dd.push({-1, -1});
cin >> a;
auto p(ar.rbegin()), k(ar.rbegin());
ll s(1);
ll px(p->second);
while(next(k) != ar.rend()){
while(p != k && s > a){
s -= p->first - next(p)->first;
s -= next(p)->second;
++p;
px += p->second;
}
if(s <= a && a <= s + p->second-1){
cout << k->first << ' ' << px - (a-s) << '\n';
break;
}
if(s + p->second <= a && a < s + p->second-1 + k->first - next(k)->first ){
cout << k->first - (a - s - p->second+1) << ' ' << px - (p->second-1) << '\n';
break;
}
++k;
s += k->second;
s += prev(k)->first - k->first;
}
break;
}
// for(auto i: ar)cout << i << ' ';
// cout << '\n';
}
return 0;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3568kb
input:
1000 - 1 999995 ? 770771330 ? 688406105220012703 ? 466054413 ? 1466199 ? 940610359316496655 ? 310504014100463831 ? 765557590 ? 419614901 ? 830584303 ? 85199513 ? 768715778674812284 ? 742663363105169125 ? 859012516258231128 ? 168409807482711289 ? 842755243 ? 618667253264707663 ? 957265852 + 1 1 + 1 1...
output:
result:
wrong output format Unexpected end of file - int64 expected
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%
Subtask #6:
score: 0
Wrong Answer
Test #111:
score: 0
Wrong Answer
time: 7ms
memory: 5744kb
input:
300000 ? 308230551 ? 154394919 ? 77796824 ? 523232316 ? 601650936815206607 ? 986805724 ? 283169431815882827 ? 781223930 ? 785380179984309713 ? 36818911074958611 ? 452850684 ? 392810692 ? 812929344 ? 9753139 ? 236758865441063408 ? 448106017 ? 382652997142237763 ? 667762111 ? 201388730 ? 433119061 ? 6...
output:
result:
wrong output format Unexpected end of file - int64 expected
Subtask #7:
score: 0
Skipped
Dependency #1:
0%