Submission #59020102


Source Code Expand

#include <bits/stdc++.h>
#include<atcoder/all>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using namespace atcoder;
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef modint1000000007 mi;
constexpr ll mod=1000000007;

int sum[2][100002];

int main(){
	int n;cin>>n;
	rep(i,n){
		int c,p;cin>>c>>p;
		sum[c-1][i+1]=p;
	}
	rep(i,2){
		rep(j,n)sum[i][j+1]+=sum[i][j];
	}
	int q;cin>>q;
	rep(i,q){
		int l,r;cin>>l>>r;
		cout<<sum[0][r]-sum[0][l-1]<<" "<<sum[1][r]-sum[1][l-1]<<endl;
	}
}

Submission Info

Submission Time
Task 010 - Score Sum Queries(★2)
User Rho17
Language C++ 20 (gcc 12.2)
Score 2
Code Size 561 Byte
Status AC
Exec Time 153 ms
Memory 4364 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 2 / 2
Status
AC × 4
AC × 18
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All hand01.txt, hand02.txt, hand03.txt, hand04.txt, hand05.txt, hand06.txt, random01.txt, random02.txt, random03.txt, random04.txt, random05.txt, random06.txt, random07.txt, random08.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
hand01.txt AC 6 ms 3468 KiB
hand02.txt AC 1 ms 3584 KiB
hand03.txt AC 152 ms 4284 KiB
hand04.txt AC 151 ms 4304 KiB
hand05.txt AC 142 ms 4364 KiB
hand06.txt AC 153 ms 4296 KiB
random01.txt AC 111 ms 3892 KiB
random02.txt AC 134 ms 4044 KiB
random03.txt AC 102 ms 3904 KiB
random04.txt AC 61 ms 3660 KiB
random05.txt AC 73 ms 3700 KiB
random06.txt AC 46 ms 3688 KiB
random07.txt AC 68 ms 3620 KiB
random08.txt AC 9 ms 3780 KiB
sample_01.txt AC 1 ms 3520 KiB
sample_02.txt AC 1 ms 3520 KiB
sample_03.txt AC 1 ms 3532 KiB
sample_04.txt AC 1 ms 3644 KiB