Submission #632055

# Submission time Handle Problem Language Result Execution time Memory
632055 2022-08-19T10:58:19 Z Jovan26 Addk (eJOI21_addk) C++14
0 / 100
394 ms 1048576 KB
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
cin.tie(NULL);
	long long n;
	cin>>n;
	long long k;
	cin>>k;
	long long  a[n];
	int rezz[n][n] = {{0}};
	for(long i=0;i<n;i++) cin>>a[i];
	long long q;
	cin>>q;
	bool p = false;
	vector<long long> v;
	long long pref[n];
	pref[0] = a[0];
	for(int i=1;i<n;i++){
		pref[i] = pref[i-1]+a[i];
	}
	for(long long j=0;j<q;j++){
		int x;
		cin>>x;
		if(x==1){
		int y;
		cin>>y;
		 continue;
		}
		long long l,r,m;
		p = true;
		cin>>l>>r>>m;
		long long ma = min(m,(r-l+1-m+1));
		long long rez1 = 0;
		if (rezz[l-1][l+ma-2]!=0) rez1+=rezz[l-1][l+ma-2];
		else{
		for(long long i=l-1;i<l+ma-2;i++){
			if(rezz[i][l+ma-2]!=0){
				rez1+=rezz[i][l+ma-2];
				break;
			}
			rez1+=(i-l+2)*a[i];
			rezz[l-1][i] = rez1;
		}
	}
		int rez2 = 0;
		for(long long i=r-1;i>r-ma;i--){
			rez2+=(r-i)*a[i];
			}
			int rez = 0;
		long long s = pref[r-ma]-pref[l+ma-3];
		rez+=s*ma;
		rez = rez+rez1+rez2;
		v.push_back(rez);
	}
	if(p){
	for(long long i=0;i<v.size()-1;i++) cout<<v[i]<<endl;
	cout<<v[v.size()-1];
}
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:57:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |  for(long long i=0;i<v.size()-1;i++) cout<<v[i]<<endl;
      |                    ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 394 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 367 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -