Submission #69075
ソースコード
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | /* #region header */ #include <bits/stdc++.h> using namespace std; using ll = long long ; #define rep(i, n) for(int i = 0;i < (int)(n);++i) #define MS(x) memset((x), -1, sizeof((x))) #define ALL(x) x.begin(), x.end() template < class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template < class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } bool is_npos(string::size_type x) { return x == string::npos; } using PI = pair< int , int >; template < class T>ostream &operator<<(ostream &os, const vector<T>&v){ if (v.size() > 0){ os << v[0]; for ( int i = 1;i < v.size();i++) os << " " << v[i]; } return os; } /* #endregion */ int main(){ int n, q; cin >> n >> q; multiset< int > st; map< int , int > mp; mp[1] = n+1; st.insert(n); rep(i, q){ int num; cin >> num; auto x = mp.upper_bound(num); x--; int l = x->first; int r = x->second; mp.erase(l); st.erase(st.find(r-l)); { int nl = l; int nr = num; if (nl != nr){ mp[nl] = nr; st.insert(nr-nl); } } { int nl = num+1; int nr = r; if (nl != nr){ mp[nl] = nr; st.insert(nr-nl); } } auto ans = st.end(); ans--; cout << *ans << endl; } return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 1528 - Monochrome Balls |
ユーザー名 | ei1719 |
投稿日時 | 2021-12-06 00:24:22 |
言語 | C++14 |
状態 | Accepted |
得点 | 4 |
ソースコード長 | 1290 Byte |
最大実行時間 | 944 ms |
最大メモリ使用量 | 64796 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 4 / 4 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in01.txt | AC | 38 ms | 604 KB |
1
|
in02.txt | AC | 22 ms | 652 KB |
1
|
in03.txt | AC | 44 ms | 612 KB |
1
|
in04.txt | AC | 25 ms | 652 KB |
1
|
in05.txt | AC | 27 ms | 604 KB |
1
|
in06.txt | AC | 45 ms | 1304 KB |
1
|
in07.txt | AC | 70 ms | 1200 KB |
1
|
in08.txt | AC | 204 ms | 5292 KB |
1
|
in09.txt | AC | 81 ms | 3152 KB |
1
|
in10.txt | AC | 593 ms | 7744 KB |
1
|
in11.txt | AC | 342 ms | 10148 KB |
1
|
in12.txt | AC | 923 ms | 13916 KB |
1
|
in13.txt | AC | 344 ms | 14012 KB |
1
|
in14.txt | AC | 308 ms | 14592 KB |
1
|
in15.txt | AC | 179 ms | 13072 KB |
1
|
in16.txt | AC | 863 ms | 18764 KB |
1
|
in17.txt | AC | 433 ms | 19520 KB |
1
|
in18.txt | AC | 850 ms | 22364 KB |
1
|
in19.txt | AC | 935 ms | 25160 KB |
1
|
in20.txt | AC | 922 ms | 28076 KB |
1
|
in21.txt | AC | 912 ms | 30852 KB |
1
|
in22.txt | AC | 944 ms | 33380 KB |
1
|
in23.txt | AC | 936 ms | 36300 KB |
1
|
in24.txt | AC | 922 ms | 39088 KB |
1
|
in25.txt | AC | 673 ms | 35856 KB |
1
|
in26.txt | AC | 671 ms | 39792 KB |
1
|
in27.txt | AC | 669 ms | 43600 KB |
1
|
in28.txt | AC | 679 ms | 47544 KB |
1
|
in29.txt | AC | 820 ms | 64796 KB |
1
|
in30.txt | AC | 190 ms | 54668 KB |
1
|
in31.txt | AC | 32 ms | 51276 KB |
1
|
sample.txt | AC | 20 ms | 51124 KB |
1
|