제출 #533354

#제출 시각아이디문제언어결과실행 시간메모리
533354idasSails (IOI07_sails)C++11
5 / 100
118 ms2748 KiB
#include <bits/stdc++.h> #define FOR(i, begin, end) for(int i = (begin); i < (end); i++) #define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr) #define f first #define s second #define pb push_back #define sz(x) ((int)((x).size())) #define le(vec) vec[vec.size()-1] #define all(x) (x).begin(), (x).end() #define TSTS int ttt; cin >> ttt; while(ttt--) solve() using namespace std; typedef pair<int, int> pii; typedef pair<long long, long long> pll; typedef pair<long double, long double> pdd; typedef map<int, int> mii; typedef vector<int> vi; typedef long double ld; typedef long long ll; const int INF=1e9, MOD=1e9+7, mod=998244353; const ll LINF=1e18; void setIO() { FAST_IO; } void setIO(string s) { FAST_IO; freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); } const int N=1e5+10; int n, mx, st, t[4*N], lazy[N], fen[N]; vector<pii> inf; void upd(int p, int x) { for(int i=p; i<N; i+=i&-i){ fen[i]+=x; } } void upd_range(int x, int y) { upd(x, 1); upd(y+1, -1); } int get(int p) { int ret=0; for(int i=p; i>0; i-=i&-i){ ret+=fen[i]; } return ret; } void get_start(int hgt, int x) { st=min(st, hgt); while(st!=0 && get(st)>=x){ st--; } } bool can(int x) { st=mx; FOR(i, 0, N) fen[i]=0; for(auto[h, k] : inf){ get_start(h, x); if(st<k) return false; upd_range(st-k+1, st); } return true; } void build(int l) { st=mx; FOR(i, 0, N) fen[i]=0; for(auto[h, k] : inf){ get_start(h, l); upd_range(st-k+1, st); } } int main() { setIO(); cin >> n; FOR(i, 0, n) { int h, k; cin >> h >> k; inf.pb({h,k}); mx=max(mx, h); } sort(all(inf), greater<pii>()); int l=0, r=n; while(l<r){ int m=(l+r)/2; if(can(m)) r=m; else l=m+1; } build(l); ll ans=0; FOR(i, 1, mx+1) { ll x=get(i); ans+=x*(x-1)/2; } cout << ans; }

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

sails.cpp: In function 'bool can(int)':
sails.cpp:74:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   74 |     for(auto[h, k] : inf){
      |             ^
sails.cpp: In function 'void build(int)':
sails.cpp:86:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   86 |     for(auto[h, k] : inf){
      |             ^
sails.cpp: In function 'void setIO(std::string)':
sails.cpp:32:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     freopen((s+".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sails.cpp:33:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     freopen((s+".out").c_str(), "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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...