Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include <algorithm>
- #define lli long long int
- #define li long int
- #define mod 1000000007
- #define ld long double
- #define F first
- #define S second
- #define PB push_back
- #define MP make_pair
- #define REP(i,a,b) for (int i = a; i < b; i++)
- using namespace std;
- int main(){
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int n;
- cin>>n;
- map<int,int> m;
- int k;
- cin>>k;
- int arr[n];
- for (int i = 0; i < n; i++)
- {
- cin>>arr[i];
- }
- for (int i = 0; i < n-k+1; i++)
- { int ans=0;
- for (int j = 0; j < k; j++)
- {
- ans=ans+arr[j];
- }
- m.insert({ans,i+1});
- }
- cout<<m.size()<<endl;
- for (auto pr:m)
- {
- cout<<pr.first<<" "<<pr.second<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment