Submission #55099
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | #include "bits/stdc++.h" // Begin {{{ #define all(x) x.begin(), x.end() #define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i) #define reps(i, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i) #define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i) #ifndef DEBUG #define dump(...) #endif using namespace std; using i64 = int_fast64_t; using pii = pair<i64, i64>; template < class T> using MaxHeap = priority_queue<T>; template < class T> using MinHeap = priority_queue<T, vector<T>, greater<>>; template < class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true ); } template < class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true ); } inline i64 sigma(i64 n) { return n * (1 + n) >> 1; } inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; } constexpr int INF = 0x3f3f3f3f; constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr int MOD = int (1e9) + 7; template < class T> inline vector<T> make_v( const T &initvalue, size_t sz) { return vector<T>(sz, initvalue); } template < class T, class ... Args> inline auto make_v( const T &initvalue, size_t sz, Args... args) { return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...)); } // }}} End signed main() { ios::sync_with_stdio( false ); cin.tie(nullptr); int N, M; cin >> N >> M; vector< int > a(N + 10); reps(i, 1, N) cin >> a[i]; reps(k, 1, M) reps(i, 1, N - 1) { if (a[i] % k > a[i+1] % k) swap(a[i], a[i+1]); } reps(i, 1, N) cout << a[i] << "\n" ; return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0258 - ゼッケンの交換 (Swapping Bibs) |
ユーザー名 | もけ |
投稿日時 | 2019-09-22 14:03:05 |
言語 | C++14 |
状態 | Accepted |
得点 | 5 |
ソースコード長 | 1659 Byte |
最大実行時間 | 33 ms |
最大メモリ使用量 | 688 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | INPUT1 | 1 / 1 | *in1.txt |
2 | INPUT2 | 1 / 1 | *in2.txt |
3 | INPUT3 | 1 / 1 | *in3.txt |
4 | INPUT4 | 1 / 1 | *in4.txt |
5 | INPUT5 | 1 / 1 | *in5.txt |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # | ||||
---|---|---|---|---|---|---|---|---|
2016-yo-t2-in1.txt | AC | 28 ms | 604 KB |
1
|
||||
2016-yo-t2-in2.txt | AC | 33 ms | 688 KB |
2
|
||||
2016-yo-t2-in3.txt | AC | 24 ms | 516 KB |
3
|
||||
2016-yo-t2-in4.txt | AC | 18 ms | 476 KB |
4
|
||||
2016-yo-t2-in5.txt | AC | 17 ms | 432 KB |
5
|
||||
2016-yo-t2-in_s1.txt | AC | 20 ms | 384 KB | |||||
2016-yo-t2-in_s2.txt | AC | 30 ms | 464 KB |