結果
問題 | No.2559 眩しい数直線 |
ユーザー |
|
提出日時 | 2023-12-02 14:47:57 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 2,646 bytes |
コンパイル時間 | 1,457 ms |
コンパイル使用メモリ | 142,268 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-26 17:25:38 |
合計ジャッジ時間 | 2,185 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include<iostream>#include<algorithm>#include<vector>#include<string>#include<map>#include<deque>#include<iomanip>#include<tuple>#include<cmath>#include<cctype>#include<fstream>#include<random>using namespace std;#define rep(i,n) for (long long i=0;i<n;i++)#define loop(i,m,n) for(long long i=m;i<=n;i++)#define range(value,range) for(const auto &value : range)#define ll long long#define vl vector<long long>#define vvl vector<vector<long long>>#define inf 4000000000000000000#define mod 998244353//#define mod 1000000007//関数bool isSqrt(ll);ll power(ll,ll);vector<ll> makePrime(ll);ll power_mod(ll,ll);ll ncr(ll,ll);string cnvString(const string &str, int mode);//乱数、ファイル入出力random_device rnd;// 非決定的な乱数生成器mt19937 mt(rnd());// メルセンヌ・ツイスタの32ビット版、引数は初期シードifstream fin("./DefaultFile");ofstream fout("./DefaultFile");//出力する場合の出力先を指定//メインint main(){ll n,x;cin>>n>>x;vl a(n);vl b(n);rep(i,n)cin>>a[i]>>b[i],a[i]--;vl l(x,0);rep(i,n){rep(j,x){l[j]=max(l[j],b[i]-abs(j-a[i]));}}rep(i,x){cout<<l[i]<<" ";}return 0;}//√の値が整数かを調べるbool isSqrt(ll n) {if (n < 0) return false;ll sqrtN = static_cast<ll>(sqrt(n));return sqrtN * sqrtN == n;}//整数同士の累乗の計算をする。ll power(ll A, ll B) {ll result = 1;for (ll i=0;i<B;i++){result *= A;}return result;}//素因数分解vector<ll> makePrime(ll n){vector<ll> factors;while (n % 2 == 0) {factors.push_back(2);n /= 2;}for (ll i=3; i*i<=n;i+=2) {while (n%i == 0) {factors.push_back(i);n /= i;}}if (n > 2) {factors.push_back(n);}return factors;}// nのk乗をmodで割った余りを計算ll power_mod(ll n, ll k) {long long result = 1;while (k > 0){if ((k&1) ==1)result=(result*n)%mod;n=n*n%mod;k >>= 1;}return result;}//場合の数 nCr を求めるll ncr(ll n,ll r) {vvl dp(n+1,vl(r+1));rep (i,n+1)dp[i][0] = 1;rep (i,r+1)dp[i][i] = 1;loop (i,1,n){loop (j,1,min((ll)i-1,r)) {//nCr= n-1Cr-1 + n-1Crdp[i][j] = dp[i-1][j-1] + dp[i-1][j];}}return dp[n][r];}//受け取った文字列を、第2引数が0なら全て小文字に、1なら大文字に変換する関数string cnvString(const string &str, int mode) {string result = str;if (mode == 0) {// 小文字に変換for (char &c : result) {c = tolower(c);}} else if (mode == 1) {// 大文字に変換for (char &c : result) {c = toupper(c);}}return result;}