結果

問題 No.81 すべて足すだけの簡単なお仕事です。
コンテスト
ユーザー fura
提出日時 2020-05-09 02:17:52
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 665 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,206 ms
コンパイル使用メモリ 215,796 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-10 01:52:15
合計ジャッジ時間 2,593 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	int n; scanf("%d",&n);
	vector<lint> a(n),b(n);
	rep(i,n){
		string s; cin>>s;
		if(count(s.begin(),s.end(),'.')==0) s+='.';
		int pos=find(s.begin(),s.end(),'.')-s.begin();
		s+=string(11-(s.length()-pos),'0');

		if(s[0]!='-'){
			a[i]=stoll(s.substr(0,pos));
			b[i]=stoll(s.substr(pos+1));
		}
		else{
			a[i]=stoll(s.substr(0,pos))-1;
			b[i]=10000000000LL-stoll(s.substr(pos+1));
		}
	}

	lint ans1=0,ans2=0;
	rep(i,n){
		ans1+=a[i];
		ans2+=b[i];
	}
	printf("%lld.%010lld\n",ans1+ans2/10000000000LL,ans2%10000000000LL);

	return 0;
}
0