Submission #1606556
Source Code Expand
#include <iostream> #include <vector> #include <algorithm> #define int long long using namespace std; typedef pair<int,int> P; signed main(){ int n,x[100000],ans[100000] = {},su = 0,ansu = 0; vector<P> vec; cin >> n; for(int i = 0;i < n;i++){ cin >> x[i]; su += x[i]; vec.push_back(P(x[i],-i)); } sort(vec.begin(),vec.end(),greater<P>()); int lind = n,lup,last = vec[0].first,sum = 0; for(int i = 0;i < n;i++){ sum += (last - vec[i].first) * i; last = vec[i].first; if(!vec[i].second){ ans[lup] = sum; ans[0] = su - ansu - sum; break; } if(lind > -vec[i].second){ if(i) ans[lup] = sum; lup = -vec[i].second; ansu += sum; sum = 0; } lind = -vec[i].second; } for(int i = 0;i < n;i++) cout << ans[i] << endl; }
Submission Info
Submission Time | |
---|---|
Task | E - Frequency |
User | hoget157 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 796 Byte |
Status | RE |
Exec Time | 196 ms |
Memory | 4336 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 | 1 ms | 1024 KB |
00_example_02.txt | AC | 2 ms | 1024 KB |
01.txt | WA | 2 ms | 1024 KB |
02.txt | WA | 13 ms | 1280 KB |
03.txt | WA | 2 ms | 1024 KB |
04.txt | WA | 3 ms | 1024 KB |
05.txt | WA | 2 ms | 1024 KB |
06.txt | WA | 2 ms | 1024 KB |
07.txt | AC | 1 ms | 1024 KB |
08.txt | WA | 2 ms | 1024 KB |
09.txt | WA | 18 ms | 1536 KB |
10.txt | WA | 2 ms | 1024 KB |
11.txt | WA | 192 ms | 3824 KB |
12.txt | WA | 187 ms | 3952 KB |
13.txt | WA | 188 ms | 3700 KB |
14.txt | WA | 190 ms | 3700 KB |
15.txt | WA | 188 ms | 3952 KB |
16.txt | RE | 142 ms | 3700 KB |
17.txt | AC | 196 ms | 4080 KB |
18.txt | RE | 137 ms | 3700 KB |
19.txt | RE | 117 ms | 3700 KB |
20.txt | WA | 184 ms | 3824 KB |
21.txt | RE | 96 ms | 1024 KB |
22.txt | RE | 95 ms | 1024 KB |
23.txt | WA | 2 ms | 1024 KB |
24.txt | WA | 13 ms | 1408 KB |
25.txt | WA | 2 ms | 1024 KB |
26.txt | WA | 3 ms | 1024 KB |
27.txt | WA | 2 ms | 1024 KB |
28.txt | AC | 191 ms | 4208 KB |
29.txt | WA | 193 ms | 4336 KB |
30.txt | AC | 190 ms | 4336 KB |
31.txt | WA | 193 ms | 4208 KB |
32.txt | WA | 192 ms | 4208 KB |
33.txt | RE | 134 ms | 3700 KB |
34.txt | RE | 138 ms | 3700 KB |
35.txt | RE | 134 ms | 3700 KB |
36.txt | RE | 135 ms | 3700 KB |
37.txt | RE | 134 ms | 3700 KB |