제출 #114285

#제출 시각아이디문제언어결과실행 시간메모리
114285popovicirobertSails (IOI07_sails)C++14
0 / 100
39 ms4984 KiB
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

using namespace std;

const int MAXH = (int) 1e5;


int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n;

    vector < vector <int> > arr(MAXH + 1);
    for(i = 1; i <= n; i++) {
        int h, k;
        cin >> h >> k;
        arr[h].push_back(k);
    }

    vector <int> cnt(MAXH + 1);

    for(int h = 1; h <= MAXH; h++) {

        for(auto &k : arr[h]) {
            /*int val = cnt[h - k + 1];

            int pos = h;
            while(cnt[pos] != val) {
                k--;
                cnt[pos--]++;
            }

            int res = 0;
            for(int step = 1 << 16; step; step >>= 1) {
                if(res + step <= MAXH && cnt[res + step] > val) {
                    res += step;
                }
            }

            while(k--) {
                cnt[++res]++;
            }*/
        }

    }

    ll ans = 0;
    for(i = 1; i <= MAXH; i++) {
        ans += 1LL * cnt[i] * (cnt[i] - 1) / 2;
    }

    cout << ans;

    //cin.close();
    //cout.close();
    return 0;
}

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

sails.cpp: In function 'int main()':
sails.cpp:33:19: warning: unused variable 'k' [-Wunused-variable]
         for(auto &k : arr[h]) {
                   ^
#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...