Instantly share code, notes, and snippets.

# IKKO-Ohta/ABC037.cpp Created Jul 21, 2017

What would you like to do?
 //------------------------------------------ // C++ templete //------------------------------------------ #include #define int long long using namespace std; //typedef //------------------------------------------ typedef pair PII; typedef vector VI; typedef vector VVI; typedef vector VS; typedef vector VP; //REPEAT //------------------------------------------ #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) //container util //------------------------------------------ #define pb push_back #define paired make_pair #define ALL(a) (a).begin(),(a).end() #define PRINT(V) for (auto v : (V)) cout << v << " " #define SORT(V) sort((V).begin(),(V).end()) #define RSORT(V) sort((V).rbegin(), (V).rend()) //constant //------------------------------------------ const int MOD = 1000000007; const int INF = 1e16; const double EPS = 1e-16; const double PI = acos(-1.0); int dx[4]={1,0,-1,0}; int dy[4]={0,1,0,-1}; //math //------------------------------------------ int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;} int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;} int GCD(int a,int b){return b?GCD(b,a%b):a;} //vector util //------------------------------------------ template ostream& operator<<(ostream& s, const vector& v) { int len = v.size(); for (int i = 0; i < len; ++i) { s << v[i]; if (i < len - 1) s << "\t"; } return s; } template ostream& operator<<(ostream& s, const vector< vector >& vv) { int len = vv.size(); for (int i = 0; i < len; ++i) { s << vv[i] << endl; } return s; } vector SLICE(const vector& v, int start=0, int end=-1) { int oldlen = v.size(); int newlen; if (end == -1 or end >= oldlen){ newlen = oldlen-start; } else { newlen = end-start; } vector nv(newlen); for (int i=0; i> N >> K; REP(i,N){ int t; cin >> t; Vec.pb(t); } int i = 0; while(1){ if (i + K > N) break; int t = 0; for(j = i; j < i+K; j++){ t += Vec[j]; } ans += t; } cout << ans << endl; }