#include #include #define MAX_SIZE 500500 int N, M, T; int A[1000], B[1000]; long long sumA[MAX_SIZE], sumB[MAX_SIZE]; int compare(const void* a, const void* b) { long long x = *(long long*)a; long long y = *(long long*)b; if(x < y) return -1; else if(x > y) return 1; return 0; } int main() { scanf("%d",&T); scanf("%d",&N); for(int i=0; i= 0) { long long temp = sumA[ptA] + sumB[ptB]; if(temp != T) { if(T > temp) ptA++; else ptB--; continue; } int same_count_A = 0; int current_sumA = sumA[ptA]; while(ptA < sumA_size && sumA[ptA] == current_sumA) { ptA++; same_count_A++; } int same_count_B = 0; int current_sumB = sumB[ptB]; while(ptB >= 0 && sumB[ptB] == current_sumB) { ptB--; same_count_B++; } ans += (long long)same_count_A * same_count_B; } printf("%lld\n",ans); return 0; }