Submission #1295362


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[1000002];
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] = { g + 1,h + 1,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);
		}
	}
	reverse(ans.begin(), ans.end());
	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 1360 Byte
Status WA
Exec Time 41 ms
Memory 6520 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 × 2
WA × 1
AC × 20
WA × 7
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 8 ms 2816 KB
1.txt AC 2 ms 2304 KB
10.txt AC 2 ms 2304 KB
11.txt AC 2 ms 2432 KB
12.txt AC 2 ms 2304 KB
13.txt WA 2 ms 2304 KB
14.txt WA 3 ms 3968 KB
15.txt AC 2 ms 2304 KB
16.txt WA 2 ms 2304 KB
17.txt AC 3 ms 3968 KB
18.txt AC 35 ms 3840 KB
19.txt WA 34 ms 3840 KB
2.txt AC 1 ms 256 KB
20.txt WA 38 ms 5760 KB
21.txt AC 36 ms 3840 KB
22.txt AC 33 ms 3840 KB
23.txt WA 41 ms 6520 KB
3.txt AC 2 ms 2304 KB
4.txt AC 2 ms 2304 KB
5.txt AC 1 ms 256 KB
6.txt AC 2 ms 2304 KB
7.txt AC 2 ms 2304 KB
8.txt AC 2 ms 2432 KB
9.txt AC 2 ms 2304 KB
sample1.txt WA 2 ms 2304 KB
sample2.txt AC 2 ms 2304 KB
sample3.txt AC 2 ms 2304 KB