結果

問題 No.9008 空白区切りで与えられる数値データの合計値を求める(テスト用)
ユーザー 塚
提出日時 2023-07-29 02:09:26
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 10,419 bytes
コンパイル時間 14,047 ms
コンパイル使用メモリ 531,028 KB
実行使用メモリ 7,264 KB
最終ジャッジ日時 2024-10-07 02:25:23
合計ジャッジ時間 14,429 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 3 ms
5,248 KB
testcase_02 AC 3 ms
5,248 KB
testcase_03 AC 4 ms
5,248 KB
testcase_04 AC 3 ms
5,248 KB
testcase_05 AC 3 ms
5,248 KB
testcase_06 AC 3 ms
5,248 KB
testcase_07 AC 5 ms
5,248 KB
testcase_08 AC 10 ms
5,248 KB
testcase_09 AC 14 ms
5,248 KB
testcase_10 AC 46 ms
6,528 KB
testcase_11 AC 29 ms
6,400 KB
testcase_12 AC 29 ms
6,528 KB
testcase_13 AC 28 ms
6,784 KB
testcase_14 AC 30 ms
6,784 KB
testcase_15 AC 30 ms
6,820 KB
testcase_16 AC 33 ms
7,264 KB
testcase_17 AC 2 ms
5,248 KB
testcase_18 AC 2 ms
5,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

// clang-format off
/* #language C++ GCC */

__attribute__((constructor)) static void io_setup() noexcept {std::ios::sync_with_stdio(false);std::cin.tie(nullptr);}
using namespace std;
#if __has_include(<atcoder/modint>)
#include <atcoder/dsu>
#include<atcoder/all>
#include <atcoder/modint>
#include <boost/multiprecision/cpp_int.hpp>
//   #include <boost/multiprecision/cpp_bin_float.hpp>
//   #include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
using namespace atcoder;
using namespace boost::multiprecision;
//   using boost::algorithm::join;
using boost::algorithm::replace_all;
//   using cpp_double = cpp_bin_float_100;
//    using mint = modint1000000007;
//     using mint = modint998244353;
#endif

#ifdef LOCAL
#include <debug_print.hpp>
#define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (static_cast<void>(0))
#endif

typedef string str;
typedef long long ll;
typedef long long lint;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef map<int,int>mii;
typedef map<lint,lint>mll;
typedef deque<int> dqi;
typedef deque<lint> dql;

template <class T, class U>
using umap = unordered_map<T, U>;

template <class T>
using uset = unordered_set<T>;

template <class T>
using mset = multiset<T>;
const int inf = INT_MAX / 2;
const lint infl = 1LL << 60;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (lint i = lint(a); i < lint(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(i, n) for (lint i = n; i >= 0LL; i--)

constexpr char nl = '\n';

#define fset fixed << setprecision(15)
#define zset setfill('0') << right
#define fcout cout << fset
#define zcout(n) cout << zset << setw(n) // nで桁指定
#define all(a) (a).begin(), (a).end()
#define rall(x) (x).rbegin(), (x).rend()
#define SUM(v) accumulate(all(v), (ll)0)
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end())
#define sz(c) (lint)(c).size()
#define len(c) (lint)(c).size()

#define pb push_back 
#define eb emplace_back
#define pf push_front
#define is insert
#define lb lower_bound
#define ub upper_bound
#define fi first
#define sc second
#define bit(n) (1LL << (n))
#define yes() cout << "Yes" << '\n'
#define no() cout << "No" << '\n'
#define yn(n) cout << ((n) ? "Yes" : "No") << '\n'
#define al(i, v) for (auto &i : v)
#define alm(it, x) for (auto it = x.begin(); it != x.end(); it++)
#define scan(x) al(i, x) cin >> i
#define out(z) al(i, z) cout << i << ' ';
#define co() cout << nl;
#define rsort(a) sort(rall(a))
#define sort_(a) sort(all(a));
#define rsort_(a) sort(rall(a));

void exit_no(void){cout<<"No"<<nl; exit(0);};
void exit_yes(void){cout<<"Yes"<<nl; exit(0);};
template <class T>
void exit_(T x){cout<<x<<nl; exit(0);};
template <class T>
vector<T> div(T n){vector<T> ret;for (T i = 1; i * i <= n; i++)if (!(n % i)){ ret.pb(i);if (i * i != n) ret.pb(n / i);}sort(all(ret)); return ret;}
template <class T>
bool is_over(T a,T b){return a>((2LL<<60)/b)?true:false;}

ll digitnum(ll x, ll b = 10){ll ret = 0; for(; x; x /= b) ret++; return ret;}

ll digitsum(ll x, ll b = 10){ll ret = 0; for(; x; x /= b) ret += x % b; return ret;}

template<class T>
T d_pow(T x, T n)
{T ret = 1;while (n > 0){if (n & 1)ret *= x;x *= x;n >>= 1;}return ret;}

template <class T>
T nPr(T n, T r)
{T i, result = 1;rep(i, r) { result *= (T)(n - i); }return result;}

template<class T>
T nCr(T n, T r){T i,result = 1;rep(i, min(r, n - r)){result *= (T)(n - i);result /= (T)(i + 1);}return result;}

template <class T>
T pow_mod(T A, T N, T M)
{T res = 1 % M;A %= M;while (N){if (N & 1)res = (res * A) % M;
A = (A * A) % M;N >>= 1;}return res;
}
bool is_prime(ll N)
{if (N <= 1)return false;if (N == 2 || N == 3)return true;if (N % 2 == 0)return false;vl A = {2, 325, 9375, 28178, 450775,9780504, 1795265022};ll s = 0, d = N - 1;while (d % 2 == 0){++s;d >>= 1;}for (auto a : A){if (a % N == 0)return true;ll t, x = pow_mod<__int128_t>(a, d, N);if (x != 1){for (t = 0; t < s; ++t){if (x == N - 1)break;x = __int128_t(x) * x % N;}if (t == s)return false;}}return true;}
// Pollard のロー法
ll gcd(ll A, ll B){A = abs(A), B = abs(B);if (B == 0)return A;else return gcd(B, A % B);}

ll pollard(ll N)
{if (N % 2 == 0)return 2;if (is_prime(N))return N;auto f = [&](ll x) -> ll {return (__int128_t(x) * x + 1) % N;};ll step = 0;while (true){++step;ll x = step, y = f(x);while (true){ll p = gcd(y - x + N, N);if (p == 0 || p == N)break;if (p != 1)return p;x = f(x);y = f(f(y));}}}

vl prime_factorize(ll N){if (N == 1)return {};ll p = pollard(N);if (p == N)return {p};vl left = prime_factorize(p);vl right = prime_factorize(N / p);left.is(left.end(), right.begin(), right.end());sort(all(left));return left;
}

vl Prime_table(ll n) {vl v(n + 1, 1);v[0] = v[1] = 0;
rep(i, 2, sqrtl(n)) if (v[i]) for (lint j = 0; i * (j + 2) < n; j++) v[i * (j + 2)] = 0;return v;}

vl sieve(lint n)
{vl res;vector<int> mem(n, 0);for (int i = 2; i < n; i++){if (mem[i]){continue;}res.push_back(i);for (int j = i; j < n; j += i){mem[j] = 1;}}return res;}

template <class T>
string to_binary(T x){string bi = bitset<64>(x).to_string();return bi;}

template<class T>
T convert_base(string s,T k){T x = stoull(s,nullptr,k);return x;}

lint convert_base2(string s){lint x = stoll(s,nullptr,(lint)2);return x;}


template <class T>
set<T> operator|(set<T> a, set<T> b)
{set<T> ret;set_union(all(a), all(b), inserter(ret, ret.begin()));return ret;}

template <class T>
mset<T> operator|(mset<T> a, mset<T> b)
{mset<T> ret;set_union(all(a), all(b), inserter(ret, ret.begin()));return ret;}

template <class T>
set<T> operator&(set<T> a, set<T> b){set<T> ret;set_intersection(all(a),all(b),inserter(ret,ret.begin()));return ret;}

template <class T>
mset<T> operator&(mset<T> a, mset<T> b){mset<T> ret;set_intersection(all(a),all(b),inserter(ret,ret.begin()));return ret;}

template <class T>
set<T> operator-(set<T> a, set<T> b)
{set<T> ret;set_symmetric_difference(all(a),all(b),inserter(ret,ret.begin()));return ret;}


template <class T>
mset<T> operator-(mset<T> a, mset<T> b)
{mset<T> ret;set_symmetric_difference(all(a),all(b),inserter(ret,ret.begin()));return ret;}

template <class... T>
void input(T &...a){(cin >> ... >> a);}
void print(){cout << '\n';}
template <class T, class... Ts>
void print(const T &a, const Ts &...b){cout << a;
   (cout << ... << (cout << ' ', b));
   cout << '\n';
}

int snx() {return getchar();}
void snx(int &a) {cin>>a;}
void snx(lint &a) {cin>>a;}
void snx(ld &a) {cin>>a;}
void snx(string &a) {cin>>a;}
void snx(ull &a) {cin>>a;}
void snx(char &a) {cin>>a;}
//void snx(cpp_int &a){ cin>>a; }

void in() {}
template <class Head, class... Tail>
void in(Head &head, Tail &...tail){snx(head);in(tail...);}
#define int_(...) int __VA_ARGS__;in(__VA_ARGS__)
#define lint_(...) lint __VA_ARGS__;in(__VA_ARGS__)
#define ld_(...) ld __VA_ARGS__;in(__VA_ARGS__)
#define string_(...) string __VA_ARGS__;in(__VA_ARGS__)
#define str_(...) string __VA_ARGS__;in(__VA_ARGS__)
#define char_(...) char __VA_ARGS__;in(__VA_ARGS__)
#define ull_(...) ull __VA_ARGS__;in(__VA_ARGS__)
//#define cpp_int_(...) cpp_int __VA_ARGS__;in(__VA_ARGS__)
#define vec_(type,ne,size)vector<type>ne(size);scan(name);
#define vi_(ne,sz) vi ne(sz);scan(ne);
#define vb_(ne,sz) vb ne(sz);scan(ne);
#define vd_(ne,sz) vd ne(sz);scan(ne);
#define vc_(ne,sz) vc ne(sz);scan(ne);
#define vl_(ne,sz) vl ne(sz);scan(ne);
#define vs_(ne,sz) vs ne(sz);scan(ne);
#define snn(h,w,a) rep(i,h)rep(j,w) cin >> a[i][j];
#define vvi_(ne,h,w) vvi ne(h,vi(w,0));snn(h,w,ne)
#define vvl_(ne,h,w) vvl ne(h,vl(w,0));snn(h,w,ne)
#define vvc_(ne,h,w) vvc ne(h,vc(w,0));snn(h,w,ne)
#define vvb_(ne,h,w) vvb ne(h,vb(w,0));snn(h,w,ne)
#define vpl_(ne,m) vpl ne(m); rep(i,m)cin>>ne[i].fi>>ne[i].sc;

template <class T>
bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }

template <class T>
bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }

#define l_rot(s, n) rotate(all(s) + (n), s.end());
#define r_rot(s, n) rotate(rall(s) + (n), s.rend());

const ld PI = acos(-1.0);
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";

// map<lint, lint> mp;
// map<lint, lint> mmp;
template <class T>
void c_compress(vector<T> &a){T i; vector<T> b = a;sort(b.begin(), b.end());b.erase(unique(b.begin(), b.end()), b.end());vector<T> res(a.size());for (T i = 0; i < a.size(); i++){auto z = lower_bound(b.begin(), b.end(), a[i]) - b.begin(); res[i] = z;
      /*mp[a[i]] = z;  // 大->小
        mmp[z] = a[i]; // 小->大*/
}}
template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

ll arith(ll x) { return x * (x + 1) / 2; }
ll arith2(ll a, ll d, ll n){return n * (2 * a + (n - 1) * d) / 2; }

template <class T>
vector<T> ret_ex(vector<T> v)
{
   T n = len(v);
   vector<T> e(n + 1, 0);
   rep(i, 1, n + 1) e[i] = e[i - 1] + v[i - 1];
   return e;
}

bool is_out(ll y,ll x,ll h,ll w){return (y<0||y>=h||x<0||x>=w);}

//頂点数n,ソート済みを返すtp,グラフG
bool t_sort(lint n, vl &tp, vvl G)
{bool jud = false;vb se(n + 1, false);vb fn(n, false);auto ddfs = [&](auto ddfs, int v) -> void
{se[v] = true;for (auto next : G[v]){if (se[next] && !fn[next])jud = true;if (se[next])continue;ddfs(ddfs, next);}fn[v] = true;tp.eb(v);};rep(i, n) if (!se[i]) ddfs(ddfs, i);reverse(all(tp));return jud;}

const vl dx = {1,0,-1,0}; 
const vl dy = {0,1,0,-1};
const vl dx8 = {1, 1, 1, 0, 0, -1, -1, -1};
const vl dy8 = {1, 0, -1, 1, -1, 1, 0, -1}; 

struct edge{lint to, cost;};

#define beg begin
template<class T>
using vv = vector<vector<T>>;

// clang-format on
bool flg(lint x, lint i)
{
   return (lint)x & (1 << i);
}

int main()
{
   lint_(n);
   vl_(a, n);
   print(SUM(a));
}
0