We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2315246 commit d4d05f6Copy full SHA for d4d05f6
1539B - Love Song.cpp
@@ -0,0 +1,28 @@
1
+// ॐ नमः शिवाय
2
+#include<bits/stdc++.h>
3
+using namespace std;
4
+#define ll long long
5
+
6
+// Code Written By: Vikash Patel
7
+// Codeforces Profile: https://codeforces.com/profile/vikashpatel
8
9
+int main()
10
+{
11
+ int n,q;
12
+ cin>>n>>q;
13
+ string s;
14
+ cin>>s;
15
+ int sum[n+1];
16
+ sum[0] = 0;
17
+ for(int i=1; i<=n; i++)
18
+ {
19
+ sum[i] = sum[i-1] + s[i-1]-96;
20
+ }
21
+ int l,r;
22
+ for(int i=0; i<q; i++)
23
24
+ cin>>l>>r;
25
+ cout<<sum[r]-sum[l-1]<<endl;
26
27
+ return 0;
28
+}
0 commit comments