Problem | prefixsums |
---|---|
User | WHEE29alt |
Submission Time | 2024-06-18 15:18:22 |
Score | 0 |
Max Time | N/A |
Max Memory | N/A |
Owl Get a Life
prefixsums.cpp: In function ‘int main()’:
prefixsums.cpp:1:43: error: ‘cin’ was not declared in this scope
1 | using namespace std;int main() {int n, q; cin >> n >> q; int a[n+1], psum[n+1];a[0] = 0;for (int x = 0;x<n;x++){cin >> a[x+1];}psum[0] = 0;for (int b = 0; b<n; b++){psum[b+1] = psum[b] + a[b+1];}for (int i = 0; i < q; i++){int l,r;cin >> l >> r;cout << psum[r] - psum[l-1] << "\n";}}
| ^~~
prefixsums.cpp:1:1: note: ‘std::cin’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?
+++ |+#include <iostream>
1 | using namespace std;int main() {int n, q; cin >> n >> q; int a[n+1], psum[n+1];a[0] = 0;for (int x = 0;x<n;x++){cin >> a[x+1];}psum[0] = 0;for (int b = 0; b<n; b++){psum[b+1] = psum[b] + a[b+1];}for (int i = 0; i < q; i++){int l,r;cin >> l >> r;cout << psum[r] - psu