Submission #1301026


Source Code Expand

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<math.h>
#include<queue>
#include<functional>
#define P pair<int,int>
using namespace std;

int BIT[2000002];
int MAX(int a) {//(1,a)の最大値
	int ans = 0;
	while (a > 0) {
		ans = max(ans, BIT[a]);
		a -= a&-a;
	}
	return ans;
}
void update(int b, int c) {//BIT[b]をcにする
	while (b < 1000002) {
		BIT[b] = max(BIT[b], c);
		b += b&-b;
	}
}
struct S {
	int h, o, ID, K;
};
S d[100000];
int K[100000];
signed main() {
	int e; scanf("%d", &e);
	for (int f = 0; f < e; f++) {
		int g, h; scanf("%d%d", &g, &h);
		d[f] = { 150000-h,150000-g,f };
	}
	sort(d, d + e, [](S a, S b) {if (a.h != b.h)return a.h < b.h; return a.ID < b.ID; });
	for (int i = 0; i < e; i++) {
		d[i].K = MAX(d[i].h) + 1;
		update(d[i].o, d[i].K);
	}
	sort(d, d + e, [](S a, S b) {if (a.K != b.K)return a.K > b.K; return a.ID < b.ID; });
	vector<int>ans;
	int now = 1 << 29;
	for (int i = 0; i < e; i++) {
		if (now >= d[i].o) {
			now = d[i].h;
			ans.push_back(d[i].ID);
		}
	}
	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++) {
		if (i)cout << " ";
		cout << ans[i] + 1;
	}
	cout << endl;
}

Submission Info

Submission Time
Task C - 仕事計画
User naoki2016
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1331 Byte
Status RE
Exec Time 2103 ms
Memory 3840 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:37:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  int e; scanf("%d", &e);
                        ^
./Main.cpp:39:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   int g, h; scanf("%d%d", &g, &h);
                                  ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
AC × 3
AC × 19
TLE × 3
RE × 5
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt
All 0.txt, 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 2.txt, 20.txt, 21.txt, 22.txt, 23.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt
Case Name Status Exec Time Memory
0.txt AC 2 ms 2304 KB
1.txt AC 2 ms 2304 KB
10.txt AC 2 ms 2304 KB
11.txt RE 99 ms 256 KB
12.txt AC 2 ms 2304 KB
13.txt AC 2 ms 2304 KB
14.txt RE 101 ms 256 KB
15.txt AC 2 ms 2304 KB
16.txt AC 2 ms 2304 KB
17.txt RE 100 ms 256 KB
18.txt AC 34 ms 3840 KB
19.txt AC 34 ms 3840 KB
2.txt TLE 2103 ms 256 KB
20.txt TLE 2103 ms 3840 KB
21.txt AC 35 ms 3840 KB
22.txt AC 33 ms 3840 KB
23.txt RE 125 ms 1792 KB
3.txt AC 2 ms 2304 KB
4.txt AC 2 ms 2304 KB
5.txt RE 99 ms 256 KB
6.txt AC 2 ms 2304 KB
7.txt AC 2 ms 2304 KB
8.txt TLE 2103 ms 256 KB
9.txt AC 2 ms 2304 KB
sample1.txt AC 2 ms 2304 KB
sample2.txt AC 2 ms 2304 KB
sample3.txt AC 2 ms 2304 KB