結果
問題 | No.3017 交互浴 |
ユーザー |
![]() |
提出日時 | 2025-01-25 23:54:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 194 ms / 2,000 ms |
コード長 | 1,997 bytes |
コンパイル時間 | 4,995 ms |
コンパイル使用メモリ | 259,828 KB |
実行使用メモリ | 19,864 KB |
最終ジャッジ日時 | 2025-01-25 23:55:58 |
合計ジャッジ時間 | 16,911 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 55 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:91:35: warning: narrowing conversion of ‘(v.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)(i + 1))) - v.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)i)))’ from ‘__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type’ {aka ‘long long int’} to ‘int’ [-Wnarrowing] 91 | init[i]=S{0,v[i+1]-v[i]};
ソースコード
/**author: shobonvipcreated: 2025.01.25 23:50:56**/#include<bits/stdc++.h>using namespace std;//* ATCODER#include<atcoder/all>using namespace atcoder;typedef modint998244353 mint;//*//* BOOST MULTIPRECISION#include<boost/multiprecision/cpp_int.hpp>using namespace boost::multiprecision;//*/typedef long long ll;#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)#define all(v) v.begin(), v.end()template <typename T> bool chmin(T &a, const T &b) {if (a <= b) return false;a = b;return true;}template <typename T> bool chmax(T &a, const T &b) {if (a >= b) return false;a = b;return true;}template <typename T> T max(vector<T> &a){assert(!a.empty());T ret = a[0];for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);return ret;}template <typename T> T min(vector<T> &a){assert(!a.empty());T ret = a[0];for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);return ret;}template <typename T> T sum(vector<T> &a){T ret = 0;for (int i=0; i<(int)a.size(); i++) ret += a[i];return ret;}struct S{long long value;int size;};using F = long long;const F ID = 8e18;S op(S a, S b){ return {a.value+b.value, a.size+b.size}; }S e(){ return {0, 0}; }S mapping(F f, S x){if(f != ID) x.value = f*x.size;return x;}F composition(F f, F g){ return (f == ID ? g : f); }F id(){ return ID; }int main(){ios_base::sync_with_stdio(false);cin.tie(NULL);int n; cin >> n;vector<ll> h(n);rep(i,0,n) {cin >> h[i];}vector<ll> v = h;v.push_back(0);sort(all(v));v.erase(unique(all(v)),v.end());vector<S> init((int)v.size()-1);rep(i,0,(int)v.size()-1){init[i]=S{0,v[i+1]-v[i]};}lazy_segtree<S,op,e,F,mapping,composition,id> seg(init);rep(i,0,n){int r = int(lower_bound(all(v),h[i])-v.begin());if(i%2==0){seg.apply(0,r,1);}else{seg.apply(0,r,0);}cout<<seg.all_prod().value<<'\n';}}