AtCoder Regular Contest 069

Submission #1357970

Source codeソースコード

#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <map>
#define int long long
using namespace std;

typedef pair<int,int> P;

int n,bit[100001];

void add(int i,int x){
	while(i <= n + 1){
		bit[i] += x;
		i += i & -i;
	}
}

int sum(int i){
	int s = 0;
	while(i){
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

signed main(){
	int a[100000],ans[100000] = {},prev = 0;
	map<int,int> mp;
	vector<P> vec;
	cin >> n;
	for(int i = 0;i < n;i++) {
		cin >> a[i];
		vec.push_back(P(a[i],i));
	}
	sort(vec.begin(),vec.end(),greater<P>());
	for(int i = n - 1;i >= 0;i--) mp[a[i]] = i;
	for(auto it = mp.begin();it != mp.end();it++){
		ans[it->second] = it->first - prev;
		prev = it->first;
	}
	for(int i = 0;i < n;i++){
		add(vec[i].second + 1,1);
		ans[vec[i].second] *= sum(n) - sum(vec[i].second);
	}
	for(int i = 0;i < n;i++) cout << ans[i] << endl;
}

Submission

Task問題 E - Frequency
User nameユーザ名 hoget157
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 927 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - 00_example_01.txt,00_example_02.txt
All 0 / 700 00_example_01.txt,00_example_02.txt,01.txt,02.txt,03.txt,04.txt,05.txt,06.txt,07.txt,08.txt,09.txt,10.txt,11.txt,12.txt,13.txt,14.txt,15.txt,16.txt,17.txt,18.txt,19.txt,20.txt,21.txt,22.txt,23.txt,24.txt,25.txt,26.txt,27.txt,28.txt,29.txt,30.txt,31.txt,32.txt,33.txt,34.txt,35.txt,36.txt,37.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_example_01.txt AC 2 ms 1024 KB
00_example_02.txt AC 2 ms 1024 KB
01.txt WA
02.txt WA
03.txt WA
04.txt WA
05.txt WA
06.txt WA
07.txt WA
08.txt WA
09.txt WA
10.txt WA
11.txt WA
12.txt WA
13.txt WA
14.txt WA
15.txt WA
16.txt AC 206 ms 4464 KB
17.txt AC 238 ms 10992 KB
18.txt WA
19.txt AC 176 ms 4464 KB
20.txt WA
21.txt AC 2 ms 1024 KB
22.txt AC 2 ms 1024 KB
23.txt WA
24.txt WA
25.txt WA
26.txt WA
27.txt WA
28.txt WA
29.txt WA
30.txt WA
31.txt WA
32.txt WA
33.txt WA
34.txt WA
35.txt WA
36.txt WA
37.txt WA