Submission #721675


Source Code Expand

#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<iomanip>
using namespace std;

int main(void) {
	
	signed long long x;
	signed long long y;
	signed long long mi;
	signed long long a = 0;
	signed long long b = 0;
	signed long long c = 1;
	signed long long l = 0;
	signed long long m = 0;
	signed long long d = 0;
	signed long long k = 0;
	signed long long ans = 0;
	vector<long> koko;
	vector<long> yoto;
	cin >> x >> y;
	for (int i = 0; i < x; i++) {
		cin >> b;
		koko.push_back(b);
		yoto.push_back(0);
	}
	if (x / 2 >= y) {
		

		for (int i = y - 1; i <= x - y; i++) {
			a += koko[i];
		}
		for (int i = 0; i < y - 1; i++) {
			b = koko[i] + koko[x - i - 1];
			d += b*c;
			c++;
		}

		signed long long j = a * y + d;
		cout << j << endl;

	}
	else {
		signed long long j = 0;
		for (int i = 0; i < x - y ; i++) {

			yoto[i] = i + 1;
			yoto[x - i - 1] = i + 1;
		}
		for (int i = x-y; i < y; i++) {

			yoto[i] = x-y+1;
			
		}
		for (int i = 0; i < x; i++) {
			l = koko.at(i);
			m = yoto.at(i);
			j += l*m;
		}
		cout << j << endl;
	}
	
	cin >> x;

	
}

Submission Info

Submission Time
Task C - 総和
User udonudon
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1188 Byte
Status AC
Exec Time 79 ms
Memory 2036 KiB

Judge Result

Set Name sample subtask1 subtask2
Score / Max Score 0 / 0 50 / 50 50 / 50
Status
AC × 2
AC × 2
AC × 22
Set Name Test Cases
sample sample01.txt, sample02.txt
subtask1 00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, sample01.txt, sample02.txt
subtask2 00.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, sample01.txt, sample02.txt
Case Name Status Exec Time Memory
00.txt AC 4 ms 256 KiB
01.txt AC 4 ms 256 KiB
02.txt AC 4 ms 256 KiB
03.txt AC 5 ms 256 KiB
04.txt AC 5 ms 256 KiB
05.txt AC 5 ms 256 KiB
06.txt AC 5 ms 256 KiB
07.txt AC 5 ms 256 KiB
08.txt AC 5 ms 256 KiB
09.txt AC 5 ms 256 KiB
10.txt AC 5 ms 256 KiB
11.txt AC 75 ms 2036 KiB
12.txt AC 76 ms 2036 KiB
13.txt AC 77 ms 2036 KiB
14.txt AC 76 ms 2036 KiB
15.txt AC 75 ms 2036 KiB
16.txt AC 77 ms 2036 KiB
17.txt AC 79 ms 2036 KiB
18.txt AC 38 ms 2036 KiB
19.txt AC 75 ms 2036 KiB
sample01.txt AC 4 ms 256 KiB
sample02.txt AC 4 ms 256 KiB