首页 > 其他分享 >无题

无题

时间:2023-04-20 18:07:58浏览次数:30  
标签:case int next Input 无题 include line


 

问题

Given an array with N elements, indexed from 1 to N. Now you will be given some queries in the form I J, your task is to find the minimum value from index I to J.


Input



Input starts with an integer T (≤ 5), denoting the number of test cases.

The first line of a case is a blank line. The next line contains two integers N (1 ≤ N ≤ 105)q (1 ≤ q ≤ 50000). The next line contains N space separated integers forming the array. There integers range in [0, 105].

The next q lines will contain a query which is in the form I J (1 ≤ I ≤ J ≤ N).


Output



For each test case, print the case number in a single line. Then for each query you have to print a line containing the minimum value between indexI and J.


Sample Input



2

 

5 3

78 1 22 12 3

1 2

3 5

4 4

 

1 1

10

1 1


Sample Output



Case 1:

1

3

12

Case 2:

10

//这是超时的

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int a[100100],b[100100];
int main()
{
	int t,T=0;
	scanf("%d",&t);
	while(t--)
	{
		int n,m,x,y;
		scanf("%d%d",&n,&m);
		for(int i=1;i<=n;i++)
			scanf("%d",&a[i]);		
		printf("Case %d:\n",++T);
		while(m--)
		{
			int j=1;
			for(int i=1;i<=n;i++)
				b[j++]=a[i];
			scanf("%d%d",&x,&y);
				sort(b+x,b+y+1);
			printf("%d\n",b[x]);
		}
	}
	return 0;
}



标签:case,int,next,Input,无题,include,line
From: https://blog.51cto.com/u_16079508/6210090

相关文章

  • 无题 (最短路)
    无题DescriptionTanvirreturnedhomefromthecontestandgotangryafterseeinghisroomdusty.Wholikestoseeadustyroomafterabrainstormingprogrammingcontest?Aftercheckingabithefoundthatthereisnobrushinhimroom.So,hecalledAtiq......
  • 无题
    //前传//这题复杂度不会算...//哦T了啊那没事了//一般来讲每次乘是等于位数的然后要乘P次//但是1e6*3.1e7显然会T飞掉//然后想到用快速幂优化3.1e7开log可以变成25左右//但是每次乘复杂度就会变成位数的平方//假设P取max值则答案有1e6位//那么最后一次乘应该是三......
  • 无题
    无题【张理琦】【不详待考】孤灯半盏寒声碎,夜阑涕落更为谁?一朝入水怎分离,留我一铜空伤悲!(作于2019年3月前后待考证)【后记】现在回想起来,这首诗似乎是用于调侃初中时期......
  • 无题
    想说些什么,但是又不知道从哪里说起。手并不颤抖着,但是却确实满脸的泪。这是无助,无能。悔恨,悲伤,埋怨。当一切都这样要如烟般消散去,我猛地要去抓住他们,却无能为力。他们,只能......
  • 无题
    (以下测试均采用hotspot虚拟机)讨论两个问题:finally以下代码输出什么importorg.junit.Test;publicclassNoneTest1{publicStringcode(){Strings......
  • 无题——随感
    ​ 我以前一直也在等一个完美的时机,但后来我看到了一句名言告诉我世界上根本就没有一切就绪,在你斗志昂扬时偏偏是个阴天,作废;在你终于翻开课本认真学习时老妈突然要和你吵......
  • 无题
     青石板,花纸伞,袅袅炊烟出低檐,雨打乌篷船; 杨柳岸,水云间,绵绵寸山似墨染,古筝声飞雁。 斜街深巷白墙远,万千过客,谁人识少年? 湖中清莲相无言,一笑倾城,余生念江南。 ......
  • JavaScript之无题之让人烦躁的模块化
    我怎么记得我好像写过相关类型的文章,但是我找遍了我的博客没有~那就再写一遍吧,其实模块化的核心内容也算不上是复杂,只不过需要整理一下,规划一下罢了。嘻嘻。开始写......
  • 无题160226
    无题160226我一个人,不悲不喜只要不想你 我一个人,不愿悲伤我要不想你 关于你的词,还会继续你,也许不是你可是还会想起2016.2.26 整理以前的图片,偶然翻到。2015......
  • 无题
    你是否曾有过一张照片,带入云雾弥漫的梦里?是否有过一首歌,是深夜辗转反侧的陪伴?有些人注定只能陪你走过那最艰难的岁月,却不能在阳光正好微分不燥的时空出现。那些记忆深......