Submission #78787

# Submission time Handle Problem Language Result Execution time Memory
78787 2018-10-08T18:39:08 Z ekrem Relativnost (COCI15_relativnost) C++
0 / 140
4000 ms 15556 KB
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 100005
using namespace std;

typedef long long ll;

ll n, c, q, a[N], b[N];
ll dp[22][N];

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld %lld",&n ,&c);
	for(int i = 1; i <= n; i++)
		scanf("%lld",a + i);
	for(int i = 1; i <= n; i++)
		scanf("%lld",b + i);
	dp[0][0] = 1;
	scanf("%lld",&q);
	while(q--){
		ll x, y, z;
		scanf("%lld %lld %lld",&x ,&y ,&z);
		a[x] = y;
		b[x] = z;
		for(int i = 1; i <= n; i++)
			for(int k = 0; k <= c; k++)
				dp[k][i] = 1ll*dp[k - (k != 0)][i - 1]*a[i] + 1ll*dp[k][i - 1]*b[i];
		cout << dp[c][n] << endl;
	}
	return 0;
}

Compilation message

relativnost.cpp: In function 'int main()':
relativnost.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld",&n ,&c);
  ~~~~~^~~~~~~~~~~~~~~~~~~~
relativnost.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",a + i);
   ~~~~~^~~~~~~~~~~~~~
relativnost.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",b + i);
   ~~~~~^~~~~~~~~~~~~~
relativnost.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&q);
  ~~~~~^~~~~~~~~~~
relativnost.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld %lld",&x ,&y ,&z);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 504 KB Output isn't correct
2 Incorrect 44 ms 628 KB Output isn't correct
3 Incorrect 47 ms 708 KB Output isn't correct
4 Execution timed out 4005 ms 4696 KB Time limit exceeded
5 Execution timed out 4005 ms 11300 KB Time limit exceeded
6 Execution timed out 4026 ms 15556 KB Time limit exceeded
7 Execution timed out 4034 ms 15556 KB Time limit exceeded
8 Execution timed out 4024 ms 15556 KB Time limit exceeded
9 Execution timed out 4035 ms 15556 KB Time limit exceeded
10 Execution timed out 4059 ms 15556 KB Time limit exceeded