提出 #48765280


ソースコード 拡げる

#include<bits/stdc++.h>
#define ll long long
#define PII pair<int,int>
 #define int long long
using namespace std;
const ll mod=1e9+7; 
const ll inf=0x3f3f3f3f;  
const ll INF=0x3f3f3f3f3f3f3f3f;  
const double eps=1e-10;  
const int N=2e5+10;
// struct node{
//     friend bool operator<(const node&a,const node&b){
//         return ;
//     }
// }
//priority_queue<ll,vector<ll>,greater<ll>>pq;
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return x*f;}
inline void write(int x){char F[200];int tmp=x>0?x:-x;if(x<0) putchar('-');int cnt=0;while(tmp>0){F[cnt++]=tmp%10+'0';tmp/=10;}while(cnt>0)putchar(F[--cnt]);}
inline int combination(int n,int k){int sum=0;if (n==k||k==0){return 1;}else{return combination(n-1,k)+combination(n-1,k-1);}}

void solve(){
    int n=read(),q=read();
    vector<int>a(n+1);
    for(int i=1;i<=n;i++){
        a[i]=read();
    }
    sort(a.begin()+1,a.end());
    vector<int>pre(n+1);
    for(int i=1;i<=n;i++){
        pre[i]=pre[i-1]+a[i];
    }
    while(q--){
        int x=read(),ans=lower_bound(pre.begin(),pre.end(),x)-pre.begin();
        if(pre[ans]!=x) ans--;
        cout<<ans<<'\n';
    }
    //puts(ans>0?"YES":"NO");
    //puts(ans>0?"Yes":"No");
}

signed main(){
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    // cout.tie(0);
    int t=1;
  //  int t=read();
    while(t--){
        solve();
    }
}

提出情報

提出日時
問題 D - Reindeer and Sleigh
ユーザ EdGrass
言語 C++ 20 (gcc 12.2)
得点 400
コード長 1525 Byte
結果 AC
実行時間 60 ms
メモリ 6400 KiB

コンパイルエラー

Main.cpp: In function ‘long long int combination(long long int, long long int)’:
Main.cpp:19:41: warning: unused variable ‘sum’ [-Wunused-variable]
   19 | inline int combination(int n,int k){int sum=0;if (n==k||k==0){return 1;}else{return combination(n-1,k)+combination(n-1,k-1);}}
      |                                         ^~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 3
AC × 27
セット名 テストケース
Sample sample00.txt, sample01.txt, sample02.txt
All sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt
ケース名 結果 実行時間 メモリ
sample00.txt AC 1 ms 3460 KiB
sample01.txt AC 1 ms 3464 KiB
sample02.txt AC 1 ms 3528 KiB
testcase00.txt AC 58 ms 6308 KiB
testcase01.txt AC 60 ms 6220 KiB
testcase02.txt AC 58 ms 6040 KiB
testcase03.txt AC 60 ms 6228 KiB
testcase04.txt AC 56 ms 5960 KiB
testcase05.txt AC 60 ms 6224 KiB
testcase06.txt AC 59 ms 6260 KiB
testcase07.txt AC 60 ms 6400 KiB
testcase08.txt AC 31 ms 6008 KiB
testcase09.txt AC 35 ms 6396 KiB
testcase10.txt AC 38 ms 6044 KiB
testcase11.txt AC 39 ms 6228 KiB
testcase12.txt AC 38 ms 5960 KiB
testcase13.txt AC 40 ms 6184 KiB
testcase14.txt AC 47 ms 6008 KiB
testcase15.txt AC 50 ms 6228 KiB
testcase16.txt AC 48 ms 6172 KiB
testcase17.txt AC 50 ms 6220 KiB
testcase18.txt AC 47 ms 6232 KiB
testcase19.txt AC 50 ms 6156 KiB
testcase20.txt AC 49 ms 6032 KiB
testcase21.txt AC 50 ms 6228 KiB
testcase22.txt AC 49 ms 6232 KiB
testcase23.txt AC 50 ms 6396 KiB