結果
問題 | No.2740 Old Maid |
ユーザー | iroha HEFFERNAN |
提出日時 | 2024-04-21 12:37:35 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 479 ms / 2,000 ms |
コード長 | 3,847 bytes |
コンパイル時間 | 2,823 ms |
コンパイル使用メモリ | 217,572 KB |
実行使用メモリ | 33,004 KB |
最終ジャッジ日時 | 2024-10-13 11:08:05 |
合計ジャッジ時間 | 14,134 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 254 ms
31,360 KB |
testcase_01 | AC | 253 ms
31,360 KB |
testcase_02 | AC | 255 ms
31,360 KB |
testcase_03 | AC | 252 ms
31,360 KB |
testcase_04 | AC | 251 ms
31,360 KB |
testcase_05 | AC | 250 ms
31,360 KB |
testcase_06 | AC | 253 ms
31,360 KB |
testcase_07 | AC | 252 ms
31,360 KB |
testcase_08 | AC | 252 ms
31,360 KB |
testcase_09 | AC | 260 ms
31,360 KB |
testcase_10 | AC | 242 ms
31,360 KB |
testcase_11 | AC | 248 ms
31,488 KB |
testcase_12 | AC | 288 ms
24,956 KB |
testcase_13 | AC | 312 ms
26,688 KB |
testcase_14 | AC | 46 ms
8,192 KB |
testcase_15 | AC | 67 ms
9,984 KB |
testcase_16 | AC | 206 ms
19,620 KB |
testcase_17 | AC | 49 ms
7,936 KB |
testcase_18 | AC | 307 ms
25,708 KB |
testcase_19 | AC | 101 ms
12,416 KB |
testcase_20 | AC | 356 ms
29,092 KB |
testcase_21 | AC | 56 ms
8,960 KB |
testcase_22 | AC | 204 ms
19,112 KB |
testcase_23 | AC | 32 ms
6,820 KB |
testcase_24 | AC | 99 ms
12,032 KB |
testcase_25 | AC | 417 ms
30,400 KB |
testcase_26 | AC | 4 ms
5,248 KB |
testcase_27 | AC | 23 ms
5,888 KB |
testcase_28 | AC | 215 ms
19,476 KB |
testcase_29 | AC | 210 ms
18,696 KB |
testcase_30 | AC | 8 ms
5,248 KB |
testcase_31 | AC | 479 ms
33,004 KB |
testcase_32 | AC | 124 ms
14,052 KB |
testcase_33 | AC | 458 ms
31,428 KB |
testcase_34 | AC | 196 ms
18,500 KB |
testcase_35 | AC | 94 ms
11,904 KB |
testcase_36 | AC | 102 ms
12,416 KB |
testcase_37 | AC | 152 ms
16,120 KB |
testcase_38 | AC | 81 ms
11,008 KB |
testcase_39 | AC | 42 ms
7,552 KB |
testcase_40 | AC | 256 ms
22,208 KB |
testcase_41 | AC | 361 ms
28,788 KB |
testcase_42 | AC | 2 ms
5,248 KB |
testcase_43 | AC | 2 ms
5,248 KB |
testcase_44 | AC | 1 ms
5,248 KB |
testcase_45 | AC | 2 ms
5,248 KB |
testcase_46 | AC | 1 ms
5,248 KB |
testcase_47 | AC | 1 ms
5,248 KB |
testcase_48 | AC | 2 ms
5,248 KB |
testcase_49 | AC | 2 ms
5,248 KB |
testcase_50 | AC | 2 ms
5,248 KB |
testcase_51 | AC | 2 ms
5,248 KB |
testcase_52 | AC | 2 ms
5,248 KB |
testcase_53 | AC | 2 ms
5,248 KB |
testcase_54 | AC | 2 ms
5,248 KB |
testcase_55 | AC | 2 ms
5,248 KB |
testcase_56 | AC | 2 ms
5,248 KB |
testcase_57 | AC | 2 ms
5,248 KB |
testcase_58 | AC | 2 ms
5,248 KB |
testcase_59 | AC | 2 ms
5,248 KB |
testcase_60 | AC | 2 ms
5,248 KB |
testcase_61 | AC | 1 ms
5,248 KB |
testcase_62 | AC | 2 ms
5,248 KB |
testcase_63 | AC | 2 ms
5,248 KB |
testcase_64 | AC | 1 ms
5,248 KB |
ソースコード
/*______ || | ||ACはこちらへ| || | || ̄ ̄ ̄ ̄ ̄ ̄ ∧_∧|| (`・ω・|| ( つ||0 uーu*/ #include <bits/stdc++.h> using namespace std; //output and debug template <class T> using V = vector<T>; template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << "P(" << p.first << ", " << p.second << ")"; } template <class T> ostream& operator<<(ostream& os,const V<T>& v) { os << "["; bool f = false; for (auto d : v) { if (f) os << ", "; f = true; os << d; } return os << "]"; } template <class T> ostream& operator<<(ostream& os,const set<T>& s) { os << "{"; bool f = false; for (auto d : s) { if (f) os << ", "; f = true; os << d; } return os << "}"; } template <class T> ostream& operator<<(ostream& os, const multiset<T>& s) { os << "{"; bool f = false; for (auto d : s) { if (f) os << ", "; f = true; os << d; } return os << "}"; } template <class T, class U> ostream& operator<<(ostream& os, const map<T, U>& s) { os << "{"; bool f = false; for (auto p : s) { if (f) os << ", "; f = true; os << p.first << ": " << p.second; } return os << "}"; } template<class T, class... Ts> void o(const T& a, const Ts&... b){ cout << a; (cout << ... << (cout << ' ', b)); cout << '\n'; } #ifdef LOCAL #define dbg(...) \ do { \ cerr << __LINE__ << " : " << #__VA_ARGS__ << " = "; \ o(__VA_ARGS__); \ cerr << endl; \ } while (false); #else #define dbg(...) #endif // input template<class... T> void in(T&... a){ (cin >> ... >> a); } template<class T> void in(vector<T>& a){ for(auto&& i : a) in(i); } template<class T, class L> void in(pair<T, L>& p){ in(p.first); in(p.second); } template<class T> void in(T& a){ cin >> a; } #define rep1(n) for(ll i = 0; i < n; ++i) #define rep2(i, n) for(ll i = 0; i < n; ++i) #define rep3(i, j, n) for(ll i = j; i < n; ++i) #define overload3(a, b, c, e, ...) e #define rep(...) overload3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__) #define rrep(i,n) for(ll i = n-1;i>=0;--i) #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() using ll = long long ; using ld = long double; using pa = pair<ll,ll>; using t2 = tuple<ll,ll>; using tu = tuple<ll,ll,ll>; using vi = vector<ll>; using vs = vector<string>; using vp = vector<pa>; using vvi = vector<vi>; using vvp = vector<vp>; using vvvi = vector<vvi>; using v4 = vector<vvvi>; using vt = vector<tu>; const ll INF = (1ll << 29); const ll inf = INF*INF; const int dx[4]={1,-1,0,0}; const int dy[4]={0,0,1,-1}; void Yes(bool i = true){ return o(i?"Yes":"No"); } //reversed priority_queue template<class T> class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {}; const ll mod = 998244353; //const ll mod = 1000000007; int main(){ ll n; in(n); vi a(n),ed(n),ans; in(a); map<ll,ll> id; set<pa> b; rep(i,n){ --a[i]; id[a[i]] = i; b.emplace(i,a[i]); } rep(i,n/2){ auto nit = id.begin(); ll x = (*nit).first,xid = (*nit).second; auto it = b.upper_bound(pa(xid,x)); if(it == b.end()){ ++nit; x = (*nit).first; xid = (*nit).second; it = b.upper_bound(pa(xid,x)); } ll y = (*it).second,yid = (*it).first; ans.push_back(x); ans.push_back(y); id.erase(id.find(x)); id.erase(id.find(y)); b.erase(pa(xid,x)); b.erase(pa(yid,y)); } rep(i,n) { ans[i] += 1; } rep(i,n){ cout << ans[i]; if(i != n-1) cout << " "; } cout << endl; }