提出 #25602066
ソースコード 拡げる
/*
ॐ
JAI SHREE RAM
Hare Krishna Hare Krishna Krishna Krishna Hare Hare
Hare Rama Hare Rama Rama Rama Hare Hare
ॐ
*/
//Written by Bhuwanesh Nainwal
#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;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
pbds;
#define fast ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL)
#define int long long int
#define vci vector<int>
#define vcvci vector<vector<int>>
#define vcpi vector<pair<int,int>>
#define vcs vector<string>
#define pb push_back
#define mpii map<int , int>
#define mpsi map<string , int>
#define mpci map<char , int>
#define umpii unordered_map<int , int>
#define umpsi unordered_map<string , int>
#define umpci unordered_map<char , int>
#define all(x) auto it = x.begin() ; it != x.end() ; it++
#define vcc vector<char>
#define vcs vector<string>
#define sti set<int>
#define stc set<char>
#define sts set<string>
#define pqmx priority_queue<int>
#define pqmn priority_queue<int , vi , greater<int>>
#define null NULL
#define ff first
#define ss second
#define stb(x) __builtin_popcount(x)
#define lzr(x) __builtin_clz(x)
#define tzr(x) __builtin_ctz(x)
#define prc(x , y) fixed << setprecision(y) << x
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define nl '\n'
using namespace std;
const int mod = 1e9 + 7;
const int INF = 1e9;
const int LINF = 1e18;
const int N = 1e4;
const int chkprc = 1e-9; // Check for precision error in double
void solve()
{
int q;
cin >> q;
multiset<int> curr;
multiset<int> all;
vci unsorted;
int i = 0;
while(q--)
{
int type;
cin >> type;
int x;
if(type == 1)
{
cin >> x;
all.insert(x);
unsorted.pb(x);
}
else if(type == 2)
{
if(curr.size() == 0)
{
cout << unsorted[i] << nl;
all.erase(all.find(unsorted[i]));
i++;
continue;
}
auto it = curr.begin();
int val = (*it);
cout << (*it) << nl;
curr.erase(it);
all.erase(all.find(val));
}
else
{
curr = all;
i = unsorted.size();
}
}
}
void local()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
int32_t main()
{
fast;
//local();
int T = 1;
// cin>>T;
while(T--)
{
solve();
}
return 0;
}
提出情報
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
0 / 500 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
00_sample_00.txt, 00_sample_01.txt |
| All |
00_sample_00.txt, 00_sample_01.txt, 01_max_random_00.txt, 01_max_random_01.txt, 01_max_random_02.txt, 02_all_1_00.txt, 03_all_1_2_00.txt, 04_all_3_00.txt, 05_unordered_hack_00.txt, 05_unordered_hack_01.txt, 06_unsort_hack_00.txt, 06_unsort_hack_01.txt, 07_sort_hack_00.txt, 07_sort_hack_01.txt, 08_mixed_hack_00.txt, 08_mixed_hack_01.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 00_sample_00.txt |
AC |
8 ms |
3484 KiB |
| 00_sample_01.txt |
AC |
2 ms |
3584 KiB |
| 01_max_random_00.txt |
AC |
71 ms |
4344 KiB |
| 01_max_random_01.txt |
AC |
91 ms |
4192 KiB |
| 01_max_random_02.txt |
AC |
131 ms |
4284 KiB |
| 02_all_1_00.txt |
AC |
116 ms |
14156 KiB |
| 03_all_1_2_00.txt |
AC |
53 ms |
4192 KiB |
| 04_all_3_00.txt |
AC |
21 ms |
3528 KiB |
| 05_unordered_hack_00.txt |
AC |
90 ms |
8632 KiB |
| 05_unordered_hack_01.txt |
AC |
88 ms |
8692 KiB |
| 06_unsort_hack_00.txt |
AC |
82 ms |
13100 KiB |
| 06_unsort_hack_01.txt |
AC |
82 ms |
13136 KiB |
| 07_sort_hack_00.txt |
TLE |
2206 ms |
13424 KiB |
| 07_sort_hack_01.txt |
TLE |
2206 ms |
13432 KiB |
| 08_mixed_hack_00.txt |
TLE |
2205 ms |
7412 KiB |
| 08_mixed_hack_01.txt |
TLE |
2205 ms |
7360 KiB |