Untitled
unknown
plain_text
a year ago
663 B
3
Indexable
#include <iostream> #include <climits> using namespace std; typedef long long ll; int i, j, n, k, tmp, p[1000001], o = -1, m = INT_MAX; int main() { cin >> n >> k; for(i = 0; i < n; i++){ cin >> tmp; p[i+1] = p[i] + tmp; } for(j = 1; j <= n; j++){ for(i = j-1; i >= 0; i--){ if(p[j] - p[i] == k){ tmp = j - i; if(m > tmp){ o = i+1; m = tmp; } break; } } } if(o == -1) cout << 0 << endl; else cout << o << " " << m << endl; return 0; }
Editor is loading...
Leave a Comment