結果
問題 | No.318 学学学学学 |
ユーザー |
![]() |
提出日時 | 2015-12-11 00:09:43 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 74 ms / 2,000 ms |
コード長 | 817 bytes |
コンパイル時間 | 596 ms |
コンパイル使用メモリ | 75,308 KB |
実行使用メモリ | 9,344 KB |
最終ジャッジ日時 | 2024-06-22 14:26:56 |
合計ジャッジ時間 | 3,085 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:19:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 19 | scanf("%d", &x); | ~~~~~^~~~~~~~~~
ソースコード
#include <cstdio> #include <iostream> #include <vector> #include <set> #include <algorithm> #include <utility> using namespace std; typedef pair<int,int> pii; int main(){ const int INF = 1010101010; int n; scanf("%d", &n); vector<pii> v(n + 1); for(int i = 0; i < n; ++i){ int x; scanf("%d", &x); v[i] = pii(-x, i); } v[n] = pii(INF, INF); sort(v.begin(), v.end()); vector<int> b(n); set<int> st; for(int i = 0; i < n; ++i){ st.insert(i); } st.insert(INF); for(int i = 0; i < n; ){ int j; int val = -v[i].first; for(j = i + 1; v[j].first == -val; ++j); int l = v[i].second, r = v[j - 1].second; for(auto it = st.lower_bound(l); *it <= r; ){ b[*it] = val; it = st.erase(it); } i = j; } for(int i = 0; i < n; ++i){ printf("%d%c", b[i], i + 1 == n ? '\n' : ' '); } }