結果
| 問題 | 
                            No.2700 Please Hack Greedy Solution!
                             | 
                    
| コンテスト | |
| ユーザー | 
                             inkyaman
                         | 
                    
| 提出日時 | 2024-03-29 22:37:27 | 
| 言語 | C++17(gcc12)  (gcc 12.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 51 ms / 500 ms | 
| コード長 | 959 bytes | 
| コンパイル時間 | 4,332 ms | 
| コンパイル使用メモリ | 154,692 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2025-01-06 11:37:13 | 
| 合計ジャッジ時間 | 4,992 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 1 | 
コンパイルメッセージ
main.cpp: In function 'll comp(std::pair<long long int, long long int>&, std::pair<long long int, long long int>&)':
main.cpp:26:1: warning: control reaches end of non-void function [-Wreturn-type]
   26 | }
      | ^
            
            ソースコード
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
#include <tuple>
using namespace std;
using ll = long long;
ll comp(pair<ll,ll> &p1, pair<ll,ll> &p2) {
    auto [vi,wi] = p1;
    auto [vj,wj] = p2;
    if(vi*wj != vj*wi) return vi*wj > vj*wi;
    else wi > wj;
}
int main() {
    vector<pair<ll,ll>> ans;
    ans.push_back({1000,1});
    for(int p = 2; p <= 1000; ++p) {
        sort(ans.begin(),ans.end(),comp);
        ll q = p, G = 0;
        for(auto [vi,wi] : ans) {
            if(wi > q) continue;
            q -= wi;
            G += vi;
        }
        ans.push_back({G+1,p});
    }
    cout << 1000 << " " << 1000 << endl;
    for(auto [vi,wi] : ans) cout << vi << " " << wi << endl;
}
            
            
            
        
            
inkyaman