結果
| 問題 | No.631 Noelちゃんと電車旅行 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-16 17:10:53 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 812 bytes |
| 記録 | |
| コンパイル時間 | 1,912 ms |
| コンパイル使用メモリ | 195,648 KB |
| 最終ジャッジ日時 | 2025-01-15 07:50:32 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 21 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:29:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
29 | int n; scanf("%d",&n);
| ~~~~~^~~~~~~~~
main.cpp:31:25: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
31 | rep(i,n-1) scanf("%lld",&a[i]);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:39:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
39 | int q; scanf("%d",&q);
| ~~~~~^~~~~~~~~
main.cpp:42:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
42 | lint d; scanf("%d%d%lld",&l,&r,&d); l--;
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using lint=long long;
template<class G>
class Fenwick_tree_dual{
vector<G> a;
public:
Fenwick_tree_dual(int n):a(n){}
void add(int l,int r,const G& val){
if(l==0){
for(;r>0;r-=r&-r) a[r-1]+=val;
return;
}
add(0,r,val);
add(0,l,-val);
}
G sum(int i)const{
G res{};
for(i++;i<=a.size();i+=i&-i) res+=a[i-1];
return res;
}
};
int main(){
int n; scanf("%d",&n);
vector<lint> a(n-1);
rep(i,n-1) scanf("%lld",&a[i]);
lint t=0;
rep(i,n-1) t=max(a[i],t)+3;
Fenwick_tree_dual<lint> F(n-1);
rep(i,n-1) F.add(i,i+1,a[i]);
int q; scanf("%d",&q);
rep(_,q){
int l,r;
lint d; scanf("%d%d%lld",&l,&r,&d); l--;
F.add(l,r,d);
t=max(t,F.sum(l)+3*(n-l-1));
printf("%lld\n",t);
}
return 0;
}