Submission #2248548
Source Code Expand
#include<iostream> #include<vector> #include<algorithm> #include<string> #include<cmath> #include<map> #include<cstdio> #include<stack> #include<queue> #include<fstream> #include<cstdio> #include<deque> using namespace std; #define ok1 printf("ok1\n"); #define ok2 printf("ok2\n"); #define M 1000000000000000000LL #define rep(i,n) for(int i=0;i<n;i++) #define REP(i,s,n) for(int i=(s);i<(n);i++) #define repr(i,n) for(int i=n-1;i>=0;i--) #define REPR(i,s,n) for(int i=(s);i>=(g);(i)--) #define all(a) (a).begin(),(a).end() #define reall(a) (a).rbegin(),(a).rend() #define pb push_back #define pf push_front #define MIN(a,b) a=min((a),(b)) #define MAX(a,b) a=max((a),(b)) #define SIZE(v) (int)v.size() const double PI = acos(-1.0); typedef vector<int> vi; typedef vector<string> vs; typedef long long ll; typedef vector<ll> vll; typedef vector<vi> vvi; typedef deque<ll> dll; ll mod = 1e9 + 7; int main() { ios::sync_with_stdio(false); cin.tie(0); long long n; cin >> n; vector<long long> a(n); long long sunu = 0, ans = M, arai = 0; for (int i = 0; i < n; i++) { cin >> a[i]; arai += a[i]; } for (int i = 0; i < n - 1; i++) { sunu += a[i]; arai -= a[i]; ans = min(ans,abs(sunu - arai)); //cout << min << endl; } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Splitting Pile |
User | side |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1331 Byte |
Status | AC |
Exec Time | 21 ms |
Memory | 1792 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 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 | AC | 11 ms | 1024 KB |
02.txt | AC | 5 ms | 512 KB |
03.txt | AC | 4 ms | 512 KB |
04.txt | AC | 14 ms | 1280 KB |
05.txt | AC | 4 ms | 512 KB |
06.txt | AC | 21 ms | 1792 KB |
07.txt | AC | 21 ms | 1792 KB |
08.txt | AC | 20 ms | 1792 KB |
09.txt | AC | 21 ms | 1792 KB |
10.txt | AC | 21 ms | 1792 KB |
11.txt | AC | 1 ms | 256 KB |
12.txt | AC | 1 ms | 256 KB |
13.txt | AC | 18 ms | 1792 KB |
14.txt | AC | 1 ms | 256 KB |