Submission #1516735
Source Code Expand
#include <iostream> #include <fstream> #include <cstdio> #include <cmath> #include <vector> #include <cstring> #include <string> #include <set> #include <map> #include <stack> #include <queue> #include <algorithm> using namespace std; #define REP(i,n) for(int i=0; i<n; ++i) #define FOR(i,a,b) for(int i=a; i<=b; ++i) #define FORR(i,a,b) for (int i=a; i>=b; --i) #define pi acos(-1.0) typedef long long ll; typedef vector<int> VI; typedef vector<ll> VL; typedef vector<VI> VVI; typedef pair<int,int> P; typedef pair<ll,ll> PL; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; priority_queue <int> maxpq; cin >> n; REP(i, n){ int a; cin >> a; maxpq.push(a); } ll x = maxpq.top(); maxpq.pop(); ll y = maxpq.top(); maxpq.pop(); while(!maxpq.empty()){ if(x > y){ if(maxpq.top() > 0){ y += maxpq.top(); }else{ x += maxpq.top(); } }else{ if(maxpq.top() > 0){ x += maxpq.top(); }else{ y += maxpq.top(); } } maxpq.pop(); } cout << abs(x - y) << "\n"; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Splitting Pile |
User | moon_light |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1289 Byte |
Status | WA |
Exec Time | 44 ms |
Memory | 1400 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | ||||||
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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 1 ms | 256 KB |
00_example_02.txt | AC | 1 ms | 256 KB |
01.txt | WA | 21 ms | 892 KB |
02.txt | WA | 8 ms | 640 KB |
03.txt | WA | 7 ms | 512 KB |
04.txt | WA | 28 ms | 892 KB |
05.txt | WA | 7 ms | 512 KB |
06.txt | WA | 44 ms | 1400 KB |
07.txt | WA | 43 ms | 1400 KB |
08.txt | WA | 43 ms | 1400 KB |
09.txt | WA | 43 ms | 1400 KB |
10.txt | WA | 43 ms | 1400 KB |
11.txt | WA | 1 ms | 256 KB |
12.txt | WA | 2 ms | 256 KB |
13.txt | WA | 39 ms | 1400 KB |
14.txt | AC | 1 ms | 256 KB |