제출 #1043585

#제출 시각아이디문제언어결과실행 시간메모리
1043585kukukHacker (BOI15_hac)C++14
100 / 100
231 ms18324 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() typedef long long ll; typedef unsigned long long int ull; const ll md = 1e9+7; const int ukr = 2e5+10; int read() { int ketek = 0; bool ne=0; register char c = getchar(); while(c == ' ' or c =='\n') c =getchar(); if(c=='-'){ne = 1; c = getchar();} while(c >= '0' and c <='9') { ketek = (ketek<<3)+(ketek<<1)+c-'0'; c = getchar();} if(ne) ketek*=-1; return ketek; } void print(int x) { if (x < 0) {putchar('-');x = -x;} int len = 0, buf[10]; if (x == 0) {putchar('0');return;} while (x > 0) {buf[len++] = x % 10; x/=10;} while (len > 0) {putchar('0' + buf[--len]);} } void File_Work(){ freopen("test.in","r",stdin); freopen("test.out","w",stdout); } ll n, m, a, b, c, d, id; struct babi{ ll x, y, id; }; struct babis{ ll x, y; }; ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } ll pgkt(ll rnx, ll rny){ if(rny == 0) return 1; ll nwrn = pgkt(rnx, rny/2); if(rny%2){ return (((nwrn*nwrn)%md)*rnx)%md; }else{ return (nwrn*nwrn)%md; } } vector<ll> v; string s; multiset<ll> ms; void solve(){ cin >> n; ll ambl = n/2; ll tet = 0; for(int i = 0; i < n; i++){ cin >> id; v.push_back(id); tet += id; } ll tot = 0, tret = 0; for(int i = 0; i < ambl; i++){ tot += v[i]; } /* 0 1 2 3 4 5 0 1 2 1 2 3 2 3 4 3 4 5 4 5 0 5 0 1 */ tret = tot; ms.insert(tot); //cout << tot << "\n"; for(int i = ambl; i < n; i++){ tot -= v[i-ambl]; tot += v[i]; ms.insert(tot); //cout << tot << "\n"; } ll ans = 0; for(int i = 0; i < n; i++){ auto it = ms.find(tret); ms.erase(it); ans = max(ans, tet-*ms.rbegin()); //cout << *ms.rend() << "\n"; tot -= v[(i-ambl+n)%n]; tot += v[i]; ms.insert(tot); //cout << tret << " " << tot << "\n"; tret -= v[i]; tret += v[(i+ambl)%n]; } cout << ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t =1; //cin >> t; for(int i = 1; i <= t; i++){ //cout << "Case " << i << ": "; solve(); } }

컴파일 시 표준 에러 (stderr) 메시지

hac.cpp: In function 'void File_Work()':
hac.cpp:25:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |  freopen("test.in","r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
hac.cpp:26:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  freopen("test.out","w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...