結果
| 問題 |
No.3017 交互浴
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-02-22 03:05:39 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,034 bytes |
| コンパイル時間 | 4,306 ms |
| コンパイル使用メモリ | 289,784 KB |
| 実行使用メモリ | 18,048 KB |
| 最終ジャッジ日時 | 2025-02-22 03:06:35 |
| 合計ジャッジ時間 | 41,934 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 55 |
ソースコード
#include <atcoder/lazysegtree.hpp>
using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define chmin(x, y) x = min(x, y)
// #include <all.hpp>
// #define int long long
int op(int a, int b) {
return a + b;
}
int e() {
return 0;
}
int mapping(int f, int x) {
if(f < 0) return x;
return f;
}
int composition(int f, int g) {
if(f == -1) return g;
return f;
}
int id() {
return -1;
}
signed main() {
int n;
cin >>n ;
vector<int> h(n);
rep(i, n) cin >> h[i];
auto hh = h;
sort(hh.begin(), hh.end());
hh.erase(unique(hh.begin(), hh.end()), hh.end());
map<int, int> mp;
rep(i, hh.size()) mp[hh[i]] = i;
lazy_segtree<int, op, e, int, mapping, composition, id> seg(hh.size()+1);
rep(i, n) {
cout << 0 << " " << mp[h[i]] + 1 << " " << 1 - i%2 << endl;
seg.apply(0, mp[h[i]]+1, 1 - i%2);
}
int ans = 0;
rep(i, hh.size()+1) {
if(seg.get(i)) {
ans += hh[i] - (i == 0 ? 0 :hh[i-1]);
}
}
cout << ans << endl;
}