結果
| 問題 |
No.1441 MErGe
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2021-02-08 16:23:30 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 630 bytes |
| コンパイル時間 | 1,805 ms |
| コンパイル使用メモリ | 194,824 KB |
| 最終ジャッジ日時 | 2025-01-18 16:24:48 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 16 TLE * 12 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | scanf("%d %d",&N,&Q);
| ~~~~~^~~~~~~~~~~~~~~
main.cpp:20:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | scanf("%lld",&S[i]);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:25:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
25 | scanf("%d %d %d",&T,&l,&r);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000000
int main(){
int N,Q;
scanf("%d %d",&N,&Q);
vector<long long> S(N,0LL);
rep(i,N){
scanf("%lld",&S[i]);
}
rep(_,Q){
int T,l,r;
scanf("%d %d %d",&T,&l,&r);
l--;r--;
if(T==1){
for(int i=l+1;i<=r;i++)S[l] += S[i];
S.erase(S.begin()+l+1,S.begin()+r+1);
}
else{
long long ans = 0LL;
for(int i=l;i<=r;i++)ans += S[i];
printf("%lld\n",ans);
}
}
return 0;
}
沙耶花