# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3667 | kaires_ | King of penalty (kriii1_K) | C++98 | 0 ms | 1672 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int p=0;
int n=0;
int *farr;
//int arr[100000]={0,};
int sum=0;
int tmp=0;
int i=0;
cin >> p;
cin >> n;
farr=(int*)malloc(n*sizeof(int));
if(farr==NULL)
{
exit(0);
}
for(i=0;i<n;i++){
cin >> farr[i];
if(i!=n-1){
tmp = tmp+farr[i];
}
}
tmp = p-tmp-1;
for(i=n-2;i>=0;i--){
sum = sum+tmp+farr[i];
tmp = tmp+farr[i];
}
printf("%d ",n-1);
printf("%d",sum);
free(farr);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |