Submission #294246

# Submission time Handle Problem Language Result Execution time Memory
294246 2020-09-08T17:59:38 Z Lawliet Nuclearia (CEOI15_nuclearia) C++17
40 / 100
321 ms 62712 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long int lli;

int n, m, k, q;

vector<lli> s;
vector<lli> indep, fact;

int main()
{
	scanf("%d %d %d",&n,&m,&k);

	s.resize( n + 2 , 0 );
	indep.resize( n + 2 , 0 ); fact.resize( n + 2 , 0 );

	for(int i = 1 ; i <= k ; i++)
	{
		lli x, a, b;
		scanf("%lld %*d %lld %lld",&x,&a,&b);

		lli L = x - a/b;
		L = max( L , 1LL );

		lli R = x + a/b;
		R = min( R , n*1LL );

		lli valLeft = a - b*x;

		fact[L] += b; fact[x + 1] -= b;
		indep[L] += valLeft; indep[x + 1] -= valLeft;

		lli valRight = a + b*x;

		fact[x + 1] -= b; fact[R + 1] += b;
		indep[x + 1] += valRight; indep[R + 1] -= valRight;
	}

	lli sumFact = 0;
	lli sumIndep = 0;

	for(int i = 1 ; i <= n ; i++)
	{
		sumFact += fact[i];
		sumIndep += indep[i];

		s[i] = s[i - 1] + sumIndep;
		s[i] += sumFact*i;
	}

	scanf("%d",&q);

	while( q-- )
	{
		int xa, xb;
		scanf("%d %*d %d %*d",&xa,&xb);

		lli area = xb - xa + 1;
		lli sum = s[xb] - s[xa - 1];

		lli ans = sum/area;
		if( (sum%area)*2 >= area ) ans++;

		printf("%lld\n",ans);
	}
}

Compilation message

nuclearia.cpp: In function 'int main()':
nuclearia.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |  scanf("%d %d %d",&n,&m,&k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~
nuclearia.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |   scanf("%lld %*d %lld %lld",&x,&a,&b);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nuclearia.cpp:52:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   52 |  scanf("%d",&q);
      |  ~~~~~^~~~~~~~~
nuclearia.cpp:57:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   57 |   scanf("%d %*d %d %*d",&xa,&xb);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 44 ms 59000 KB Output is correct
2 Correct 102 ms 4600 KB Output is correct
3 Correct 100 ms 4064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 58988 KB Output is correct
2 Correct 131 ms 4728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 192 ms 62712 KB Output is correct
2 Correct 109 ms 5356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 165 ms 27384 KB Output is correct
2 Correct 101 ms 4600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 119 ms 4216 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 148 ms 15864 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 319 ms 62584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 321 ms 62712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 231 ms 3832 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 257 ms 3704 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 210 ms 3836 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 228 ms 3960 KB Output isn't correct
2 Halted 0 ms 0 KB -