제출 #43968

#제출 시각아이디문제언어결과실행 시간메모리
43968model_codeWorst Reporter 3 (JOI18_worst_reporter3)C++17
100 / 100
618 ms3672 KiB
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<ll, pii>pi3;
int main()
{
	int num, query;
	scanf("%d%d", &num, &query);
	ll dif = 1;
	int beg = 0;
	vector<pi3>v;
	for (int i = 1; i <= num; i++)
	{
		ll z;
		scanf("%lld", &z);
		if (z > dif)
		{
			v.push_back(make_pair(dif, make_pair(beg, i - 1)));
			dif = (z + dif - 1) / dif*dif;
			beg = i;
		}
	}
	v.push_back(make_pair(dif, make_pair(beg, num)));
	for (int p = 0; p < query; p++)
	{
		ll zt, zl, zr;
		scanf("%lld%lld%lld", &zt, &zl, &zr);
		ll ans = 0;
		for (int i = 0; i < v.size(); i++)
		{
			ll end = zt / v[i].first*v[i].first - v[i].second.first;
			ll beg = end + v[i].second.first - v[i].second.second;
			ans += max(0LL, min(zr, end) - max(zl, beg) + 1);
		}
		printf("%lld\n", ans);
	}
}

컴파일 시 표준 에러 (stderr) 메시지

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:32:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < v.size(); i++)
                   ~~^~~~~~~~~~
worst_reporter3.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &num, &query);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
worst_reporter3.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &z);
   ~~~~~^~~~~~~~~~~~
worst_reporter3.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld%lld", &zt, &zl, &zr);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...