結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー h_nosonh_noson
提出日時 2016-03-13 16:01:01
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,040 bytes
コンパイル時間 2,414 ms
コンパイル使用メモリ 69,352 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-26 03:20:28
合計ジャッジ時間 3,700 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,348 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 WA -
testcase_16 AC 1 ms
4,348 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
4,348 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
4,348 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;

#define RREP(i,s,e) for (i = e-1; i >= s; i--)
#define rrep(i,n) RREP(i,0,n)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1e8

typedef long long ll;

int main() {
    int i, n;
    ll ua, la;
    cin >> n;
    ua = la = 0;
    rep (i,n) {
        string s;
        ll u, l = 0;
        size_t len;
        cin >> s;
        u = stoll(s,&len);
        if (len < s.size()) {
            string t;
            t = s.substr(len+1);
            while (t.size() < 10)
                t.push_back('0');
            l = stoll(t);
        }
        ua += u;
        if (stod(s) * ua > 0)
            la += l;
        else
            la -= l;
        if (la < 0) {
            la += 10000000000;
            if (ua > 0)
                ua--;
            else
                ua++;
        }
    }
    cout << ua + la / 10000000000 << '.' << setw(10) << setfill('0') << la % 10000000000 << endl;
    return 0;
}
0