結果

問題 No.885 アマリクエリ
ユーザー kotamanegikotamanegi
提出日時 2019-09-13 21:59:31
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,863 bytes
コンパイル時間 1,250 ms
コンパイル使用メモリ 114,848 KB
実行使用メモリ 10,900 KB
最終ジャッジ日時 2023-08-20 12:55:34
合計ジャッジ時間 4,248 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
long long ans[1000000] = {};
int main(){
	iostream::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	set<long long> queries;
	vector<long long> A;
	REP(i, n) {
		long long b;
		cin >> b;
		A.push_back(b);
	}
	int query;
	cin >> query;
	int back;
	cin >> back;
	queries.insert(-back * (1e9+1) + 1);
	REP(i, query - 1) {
		int a;
		cin >> a;
		if (back > a) {
			back = a;
			queries.insert(-a * (1e9+1) + i + 2);
		}
	}
	for (int i = 0; i < n; ++i) {
		ans[0] += A[i];
		long long now = A[i];
		while (true) {
			auto q = queries.lower_bound(-(now) * (1e9+1));
			if (q == queries.end()) break;
			long long value = -*q;
			long long moto_value = ((value / (1e9+1)) + 1) * (1e9+1);
			moto_value /= 1e9 + 1;
			long long itr = moto_value * (1e9+1) - value;
			if (itr > 1000000) {
				break;
			}
			long long next = now % moto_value;
			ans[itr] -= now - next;
			now = next;
		}
	}
	for (int i = 1; i <= query; ++i) {
		ans[i] += ans[i - 1];
		cout << ans[i] << endl;
	}
}
0