結果

問題 No.885 アマリクエリ
ユーザー kotatsugamekotatsugame
提出日時 2019-09-16 19:51:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 217 ms / 2,000 ms
コード長 738 bytes
コンパイル時間 668 ms
コンパイル使用メモリ 78,792 KB
実行使用メモリ 5,432 KB
最終ジャッジ日時 2023-09-21 08:05:31
合計ジャッジ時間 4,171 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 212 ms
4,376 KB
testcase_01 AC 214 ms
4,380 KB
testcase_02 AC 216 ms
5,432 KB
testcase_03 AC 216 ms
4,896 KB
testcase_04 AC 210 ms
4,376 KB
testcase_05 AC 187 ms
4,380 KB
testcase_06 AC 158 ms
4,384 KB
testcase_07 AC 39 ms
4,376 KB
testcase_08 AC 169 ms
4,384 KB
testcase_09 AC 217 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 4 ms
4,376 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N;
int A[1<<17],X[1<<17];
long sum[1<<17];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	int Q;cin>>Q;
	for(int i=0;i<Q;i++)cin>>X[i];
	vector<pair<int,int> >Y;
	Y.push_back(make_pair(X[0],0));
	for(int i=1;i<Q;i++)
	{
		if(X[i]<Y.back().first)
		{
			Y.push_back(make_pair(X[i],i));
		}
	}
	sort(Y.begin(),Y.end());
	long SA=0;
	for(int i=0;i<N;i++)
	{
		SA+=A[i];
		int now=A[i];
		while(true)
		{
			vector<pair<int,int> >::iterator it=
				upper_bound(Y.begin(),Y.end(),make_pair(now,Q));
			if(it==Y.begin())break;
			it--;
			sum[it->second]-=now-now%it->first;
			now%=it->first;
		}
	}
	for(int i=0;i<Q;i++)
	{
		cout<<(SA+=sum[i])<<endl;
	}
}
0