Submission #279641

# Submission time Handle Problem Language Result Execution time Memory
279641 2020-08-22T08:54:43 Z arnold518 A Game with Grundy (CCO20_day1problem1) C++14
25 / 25
226 ms 16356 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5;

int N;
ll L, R, Y;
map<ll, int> M;
ll ans[MAXN+10];

int main()
{
	scanf("%d", &N);
	scanf("%lld%lld%lld", &L, &R, &Y);
	for(int i=1; i<=N; i++)
	{
		ll x, v, h;
		scanf("%lld%lld%lld", &x, &h, &v);
		ll d=(v*Y+h-1)/h-1;
		ll l=x-d, r=x+d;

		l=max(l, L);
		r=min(r, R);
		if(l<=r)
		{
			M[l]++;
			M[r+1]--;
		}
	}

	M[L]; M[R+1];

	int sum=0;
	for(auto it=M.begin(); next(it)!=M.end(); it++)
	{
		sum+=it->second;
		ans[sum]+=next(it)->first-it->first;
	}

	for(int i=1; i<=N; i++) ans[i]+=ans[i-1];
	for(int i=0; i<=N; i++) printf("%lld\n", ans[i]);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |  scanf("%d", &N);
      |  ~~~~~^~~~~~~~~~
Main.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |  scanf("%lld%lld%lld", &L, &R, &Y);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |   scanf("%lld%lld%lld", &x, &h, &v);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 140 ms 9336 KB Output is correct
4 Correct 171 ms 13816 KB Output is correct
5 Correct 185 ms 13560 KB Output is correct
6 Correct 72 ms 3192 KB Output is correct
7 Correct 70 ms 7160 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 140 ms 9336 KB Output is correct
4 Correct 171 ms 13816 KB Output is correct
5 Correct 185 ms 13560 KB Output is correct
6 Correct 72 ms 3192 KB Output is correct
7 Correct 70 ms 7160 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 171 ms 16204 KB Output is correct
10 Correct 172 ms 16356 KB Output is correct
11 Correct 204 ms 16248 KB Output is correct
12 Correct 226 ms 16064 KB Output is correct
13 Correct 93 ms 10616 KB Output is correct