結果
| 問題 |
No.854 公平なりんご分配
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2019-08-03 01:55:41 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,725 bytes |
| コンパイル時間 | 579 ms |
| コンパイル使用メモリ | 85,808 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-05 08:23:06 |
| 合計ジャッジ時間 | 4,505 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 8 WA * 84 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:76:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
76 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:82:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
82 | scanf("%d", &ai);
| ~~~~~^~~~~~~~~~~
main.cpp:88:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
88 | scanf("%d", &q);
| ~~~~~^~~~~~~~~~
main.cpp:92:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
92 | scanf("%d%d%d", &p, &l, &r);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 854.cc: No.854 公平なりんご分配 - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_N = 100000;
const int MAX_E2 = 1 << 18; // 262144
/* typedef */
template <typename T, const int MAX_E2>
struct SegTreeSum {
int n, e2;
T nodes[MAX_E2];
SegTreeSum() {}
void init(int _n) {
n = _n;
for (e2 = 1; e2 < n; e2 <<= 1);
}
T &get(int i) { return nodes[e2 - 1 + i]; }
void set(int i, T v) { get(i) = v; }
void setall() {
for (int j = e2 - 2; j >= 0; j--)
nodes[j] = nodes[j * 2 + 1] + nodes[j * 2 + 2];
}
T sum_range(int r0, int r1, int k, int i0, int i1) {
if (r1 <= i0 || i1 <= r0) return 0;
if (r0 <= i0 && i1 <= r1) return nodes[k];
int im = (i0 + i1) / 2;
T v0 = sum_range(r0, r1, k * 2 + 1, i0, im);
T v1 = sum_range(r0, r1, k * 2 + 2, im, i1);
return v0 + v1;
}
T sum_range(int r0, int r1) { return sum_range(r0, r1, 0, 0, e2); }
};
/* global variables */
int as[MAX_N];
SegTreeSum<int,MAX_E2> st;
/* subroutines */
/* main */
int main() {
int n;
scanf("%d", &n);
st.init(n);
for (int i = 0; i < n; i++) {
int ai;
scanf("%d", &ai);
st.set(i, ai);
}
st.setall();
int q;
scanf("%d", &q);
while (q--) {
int p, l, r;
scanf("%d%d%d", &p, &l, &r);
l--;
if (st.sum_range(l, r) % p == 0) puts("Yes");
else puts("NO");
}
return 0;
}
tnakao0123