Submission #42212817


Source Code Expand

#include<cstdio>
#include<cstring>
#include<set>
#define N 210000
#define fep(i,x,y) for(int i=x;i<=y;i++)
using namespace std;
typedef pair<int,int> PII;
inline int mymin(int x,int y){return x<y?x:y;}
inline int mymax(int x,int y){return x>y?x:y;}
set<PII> fuck;
int n;
int main(){
	scanf("%d",&n);
	fep(i,1,n){
		int l,r;scanf("%d%d",&l,&r);
		set<PII>::iterator x=fuck.lower_bound(make_pair(l,0));
		if(x!=fuck.begin())l=mymax(prev(x)->second+1,l);
		if(l>r)continue;
		int cnt=r-l+1;
		while(x!=fuck.end() && cnt){
			if(x->second-x->first+1<=cnt){
				cnt-=x->second-x->first+1;
				fuck.erase(x++);
			}
			else{
				fuck.insert(make_pair(x->first+cnt,x->second));
				cnt=0;
				fuck.erase(x++);
			}
		}
		fuck.insert(make_pair(l,r));
	}
	int ans=0;
	for(PII x:fuck)ans+=x.second-x.first+1;
	printf("%d\n",ans);
	return 0;
}

Submission Info

Submission Time
Task D - LIS 2
User juruozjj
Language C++ (GCC 9.2.1)
Score 600
Code Size 870 Byte
Status AC
Exec Time 129 ms
Memory 12608 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:13:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   13 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
./Main.cpp:15:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   15 |   int l,r;scanf("%d%d",&l,&r);
      |           ~~~~~^~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 48
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_srnd_00.txt, 01_srnd_01.txt, 01_srnd_02.txt, 01_srnd_03.txt, 01_srnd_04.txt, 01_srnd_05.txt, 01_srnd_06.txt, 01_srnd_07.txt, 01_srnd_08.txt, 01_srnd_09.txt, 02_rnd_00.txt, 02_rnd_01.txt, 02_rnd_02.txt, 02_rnd_03.txt, 02_rnd_04.txt, 02_rnd_05.txt, 02_rnd_06.txt, 02_rnd_07.txt, 02_rnd_08.txt, 02_rnd_09.txt, 03_fixlen_00.txt, 03_fixlen_01.txt, 03_fixlen_02.txt, 03_fixlen_03.txt, 03_fixlen_04.txt, 03_fixlen_05.txt, 03_fixlen_06.txt, 03_fixlen_07.txt, 04_sorted_00.txt, 04_sorted_01.txt, 04_sorted_02.txt, 04_sorted_03.txt, 05_max_00.txt, 05_max_01.txt, 05_max_02.txt, 05_max_03.txt, 05_max_04.txt, 06_one_00.txt, 06_one_01.txt, 07_hand_00.txt, 07_hand_01.txt, 07_hand_02.txt, 08_sqrt_00.txt, 08_sqrt_01.txt, 08_sqrt_02.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 8 ms 3144 KiB
00_sample_01.txt AC 2 ms 3256 KiB
00_sample_02.txt AC 2 ms 3232 KiB
01_srnd_00.txt AC 2 ms 3216 KiB
01_srnd_01.txt AC 2 ms 3148 KiB
01_srnd_02.txt AC 2 ms 3172 KiB
01_srnd_03.txt AC 2 ms 3232 KiB
01_srnd_04.txt AC 2 ms 3200 KiB
01_srnd_05.txt AC 3 ms 3112 KiB
01_srnd_06.txt AC 2 ms 3236 KiB
01_srnd_07.txt AC 1 ms 3140 KiB
01_srnd_08.txt AC 2 ms 3148 KiB
01_srnd_09.txt AC 2 ms 3192 KiB
02_rnd_00.txt AC 43 ms 3256 KiB
02_rnd_01.txt AC 41 ms 3228 KiB
02_rnd_02.txt AC 45 ms 3228 KiB
02_rnd_03.txt AC 62 ms 3192 KiB
02_rnd_04.txt AC 59 ms 3208 KiB
02_rnd_05.txt AC 59 ms 3300 KiB
02_rnd_06.txt AC 52 ms 3288 KiB
02_rnd_07.txt AC 52 ms 3172 KiB
02_rnd_08.txt AC 51 ms 3288 KiB
02_rnd_09.txt AC 52 ms 3116 KiB
03_fixlen_00.txt AC 82 ms 3232 KiB
03_fixlen_01.txt AC 81 ms 3280 KiB
03_fixlen_02.txt AC 82 ms 3336 KiB
03_fixlen_03.txt AC 81 ms 3188 KiB
03_fixlen_04.txt AC 83 ms 3248 KiB
03_fixlen_05.txt AC 80 ms 3340 KiB
03_fixlen_06.txt AC 83 ms 3248 KiB
03_fixlen_07.txt AC 81 ms 3224 KiB
04_sorted_00.txt AC 103 ms 12608 KiB
04_sorted_01.txt AC 49 ms 3284 KiB
04_sorted_02.txt AC 93 ms 7888 KiB
04_sorted_03.txt AC 51 ms 3204 KiB
05_max_00.txt AC 48 ms 3112 KiB
05_max_01.txt AC 47 ms 3256 KiB
05_max_02.txt AC 53 ms 3284 KiB
05_max_03.txt AC 129 ms 12564 KiB
05_max_04.txt AC 47 ms 3184 KiB
06_one_00.txt AC 2 ms 3184 KiB
06_one_01.txt AC 2 ms 3112 KiB
07_hand_00.txt AC 56 ms 3184 KiB
07_hand_01.txt AC 56 ms 3260 KiB
07_hand_02.txt AC 97 ms 7896 KiB
08_sqrt_00.txt AC 57 ms 3188 KiB
08_sqrt_01.txt AC 57 ms 3228 KiB
08_sqrt_02.txt AC 56 ms 3184 KiB