Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
sa
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#include<bits/stdc++.h> using namespace std; #define mem(A) memset(A,0,sizeof(A)) #define loop(i,a,n) for(i=a;i<n;i++) #define pb push_back #define mkp make_pair struct comp{ bool operator()(const pair<long,long>& a,const pair<long,long>& b) { if(a.first>b.first) return 1; else if(a.first==b.first) if(a.second>b.second) return 1; return 0; } }; typedef long long ll; int main() { //freopen("input.txt", "r", stdin); ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); long c,p,n,x,k,i; long B[100005],P[100005]={0}; priority_queue<pair<long,long>,vector<pair<long,long>>,comp > A; cin>>c>>p>>n; loop(i,0,n) { cin>>x; B[i]=x; A.push(make_pair(x,i)); P[i]++; } loop(k,i,c) A.push(make_pair(0,k)); loop(i,0,p) { cin>>x; //long k=A.top().first; long j=A.top().second; A.pop(); cout<<j+1<<" "; P[j]++; long v=(B[j]+x)*P[j]; B[j]=x; A.push(make_pair(v,j)); } /* while(A.size()) { cout<<A.top().first<<" "<<A.top().second<<endl; A.pop(); } */ // loop(i,0,n) }
g++
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
edit mode
|
history
|
discussion