提出 #27805690


ソースコード 拡げる

# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
# define int long long
# define fi first
# define se second

using namespace std;

const int N = 2e5 + 7;
const int mod = 1e9 + 7;
const int INF = 1e18 + 7;

int A[N], B[N], C[N], D[N];

int32_t main() {
   speed;
   int n;
   cin >> n;
   multiset < int > st, st2;
   deque < int > q;
   int sz = 0, rem = 0;
   for ( int i = 1; i <= n; i++ ) {
      int t;
      cin >> t;
      if ( t == 1 ) {
         int x;
         cin >> x;
         q.push_back(x);
         st2.insert(x);
         sz++;
      }
      else if ( t == 2 ) {
         if (rem == 0) {
            int x = q.front();
            cout << x << '\n';
            sz--;
            st2.erase(st2.find(x));
            q.pop_front();
         }
         else {
            int x = *st.begin();
            cout << x << '\n';
            st.erase(st.begin());
            st2.erase(st2.find(x));
            rem--;
            sz--;
         }
      }
      else {
         rem = sz;
         q.clear();
         st = st2;
      }
   }
}

提出情報

提出日時
問題 E - Sorting Queries
ユーザ Dilshod_Imomov
言語 C++ (GCC 9.2.1)
得点 0
コード長 1154 Byte
結果 TLE
実行時間 2206 ms
メモリ 14560 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 500
結果
AC × 2
AC × 12
TLE × 4
セット名 テストケース
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 6 ms 3456 KiB
00_sample_01.txt AC 2 ms 3472 KiB
01_max_random_00.txt AC 71 ms 3464 KiB
01_max_random_01.txt AC 88 ms 3556 KiB
01_max_random_02.txt AC 129 ms 3444 KiB
02_all_1_00.txt AC 117 ms 14560 KiB
03_all_1_2_00.txt AC 51 ms 3556 KiB
04_all_3_00.txt AC 17 ms 3472 KiB
05_unordered_hack_00.txt AC 86 ms 8972 KiB
05_unordered_hack_01.txt AC 85 ms 8968 KiB
06_unsort_hack_00.txt AC 81 ms 12924 KiB
06_unsort_hack_01.txt AC 78 ms 12856 KiB
07_sort_hack_00.txt TLE 2206 ms 12544 KiB
07_sort_hack_01.txt TLE 2206 ms 12664 KiB
08_mixed_hack_00.txt TLE 2205 ms 6912 KiB
08_mixed_hack_01.txt TLE 2205 ms 6916 KiB