Submission #1677668
Source Code Expand
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const int INF = (1LL<<30);
#else
const ll INF = (1LL<<60);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
int a[100010], cnt[100010], l[100010], ans[100010];
// xx, yy, zzにそれぞれ座圧する元の配列を突っ込むとx, y, zが座圧された配列で返ってくる
// zip[座圧前] = 座圧後、unzip[座圧後] = 座圧前
VL xx, x, unzip(100010);
unordered_map<int, int> zip;
void compress() {
x = xx;
sort(ALL(xx));
xx.erase(unique(ALL(xx)), xx.end());
REP(i, xx.size()) {zip[xx[i]] = i; unzip[i] = xx[i];}
REP(i, x.size()) x[i] = zip[x[i]];
}
signed main(void)
{
int n;
cin >> n;
REP(i, n) {
cin >> a[i];
xx.PB(a[i]);
}
compress();
memset(l, -1, sizeof(l));
int ma = 0;
REP(i, n) {
chmax(ma, (int)x[i]);
cnt[x[i]]++;
if(l[x[i]] == -1) l[x[i]] = i;
}
for(int i=ma; i>=1; --i) cnt[i-1] += cnt[i];
// REP(i, n) cout << x[i] << " "; cout << endl;
// REP(i, ma+1) cout << cnt[i] << " "; cout << endl;
REP(i, ma+1) {
int tmp;
if(i == 0) tmp = xx[i];
else tmp = xx[i] - xx[i-1];
ans[l[i]] += cnt[i] * tmp;
// cout << cnt[i] << " " << tmp << endl;
// REP(j, n) cout << ans[j] << " "; cout << endl;
}
REP(i, n) cout << ans[i] << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
E - Frequency |
User |
ferin_tech |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2024 Byte |
Status |
WA |
Exec Time |
223 ms |
Memory |
10740 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 700 |
Status |
|
|
Set Name |
Test Cases |
Sample |
00_example_01.txt, 00_example_02.txt |
All |
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 |
Case Name |
Status |
Exec Time |
Memory |
00_example_01.txt |
AC |
3 ms |
1916 KB |
00_example_02.txt |
AC |
2 ms |
1792 KB |
01.txt |
WA |
2 ms |
1792 KB |
02.txt |
WA |
15 ms |
2304 KB |
03.txt |
WA |
2 ms |
1792 KB |
04.txt |
WA |
3 ms |
1920 KB |
05.txt |
WA |
2 ms |
1792 KB |
06.txt |
WA |
2 ms |
1792 KB |
07.txt |
WA |
2 ms |
1792 KB |
08.txt |
WA |
2 ms |
1792 KB |
09.txt |
WA |
20 ms |
2432 KB |
10.txt |
WA |
2 ms |
1792 KB |
11.txt |
WA |
200 ms |
8436 KB |
12.txt |
WA |
202 ms |
8436 KB |
13.txt |
WA |
200 ms |
8436 KB |
14.txt |
WA |
200 ms |
8436 KB |
15.txt |
WA |
205 ms |
9460 KB |
16.txt |
AC |
196 ms |
4468 KB |
17.txt |
AC |
207 ms |
10356 KB |
18.txt |
WA |
211 ms |
10356 KB |
19.txt |
AC |
169 ms |
4468 KB |
20.txt |
WA |
197 ms |
7412 KB |
21.txt |
AC |
2 ms |
1792 KB |
22.txt |
AC |
2 ms |
1792 KB |
23.txt |
WA |
2 ms |
1792 KB |
24.txt |
WA |
15 ms |
2304 KB |
25.txt |
WA |
2 ms |
1792 KB |
26.txt |
WA |
3 ms |
1920 KB |
27.txt |
WA |
2 ms |
1792 KB |
28.txt |
WA |
212 ms |
10740 KB |
29.txt |
WA |
219 ms |
10740 KB |
30.txt |
WA |
217 ms |
10740 KB |
31.txt |
WA |
223 ms |
10740 KB |
32.txt |
WA |
218 ms |
10740 KB |
33.txt |
WA |
211 ms |
10740 KB |
34.txt |
WA |
213 ms |
10740 KB |
35.txt |
WA |
215 ms |
10740 KB |
36.txt |
WA |
215 ms |
10740 KB |
37.txt |
WA |
215 ms |
10740 KB |