結果

問題 No.1537 私の代わりに仕事やっといてください。
ユーザー pepper_aobutapepper_aobuta
提出日時 2021-05-22 06:42:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 2,205 bytes
コンパイル時間 1,070 ms
コンパイル使用メモリ 93,280 KB
実行使用メモリ 9,388 KB
最終ジャッジ日時 2023-08-17 18:35:54
合計ジャッジ時間 2,664 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 122 ms
9,388 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 AC 11 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:74:23: 警告: ‘memo’ may be used uninitialized [-Wmaybe-uninitialized]
   74 |     for(int i = 0 ; i < memo ; i++){
      |                     ~~^~~~~~
main.cpp:66:9: 備考: ‘memo’ はここで定義されています
   66 |     int memo;
      |         ^~~~

ソースコード

diff #

#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;
using ll = long long;





int main(){
    
    int n;
    cin >> n;
    
    vector< pair<ll,int> > a;
    for(int i = 0 ; i < n ; i++){
        ll b;
        cin >> b;
        pair<ll,int> p = make_pair(b , i + 1);
        a.push_back(p);
    }
    
    sort(a.begin(),a.end());
    
    vector<int> ans;
    for(int i = 0 ; 2 * i + 1 < n ; i++){
        ans.push_back(a[2 * i + 1].second);
    }
    for(int i = (n - 1) / 2 ; 2 * i >= 0 ; i--){
        ans.push_back(a[2 * i].second);
    }
    
    int memo;
    for(int i = 0 ; i < ans.size() ; i++){
        if(ans[i] == 1){
            memo = i;
            break;
        }
    }
    
    for(int i = 0 ; i < memo ; i++){
        ans.push_back(ans[i]);
    }
    
    ans.erase(ans.begin(),ans.begin() + memo);
    
    for(int i = 0 ; i < ans.size() ; i++){
        cout << ans[i] << " ";
    }
    cout << 1;
    return 0;
}
0